So I've written a few comprehensive scripts using bash
and sh
, but only a couple of small java programs. I've read a couple of java books and just feel like it isn't sticking. I find C and C++ easier to grasp for some odd reason and then scripting to just be immensely more simple.
One of the big gaps in my understanding between scripting and programming is understanding how programs are processed. For example, in a script, I can do the following:
#!/bin/sh
var="my variable"
echo "$var"
Obviously this will print my variable
. I understand that this basically works as if I typed this into the shell as commands with echo
being the command and $var
being the argument to echo
and the script just processes these commends sequentualy. But if I do this in java:
String var = "my variable"
System.out.println(var);
What is the difference in how the computer is processing the commands or are these even commands? For the first line, is String
a command to the jvm and var
the argument?
I understand that these are differences in syntax and I understand how that code works, but under the hood, what is the difference between how a shell script processes commands versus the jvm? Or am I looking at this totally wrong?