Here’s my answer for you… I hope that you find it helpful, but I also hope someone will come along and clear up all the mistakes I’m going to make.
The simple answer to your question “how does the computer understand it?” is that by itself, the computer can’t understand it. In order for everything to work, the creator of a programming language must provide some way to translate his language into a form that the computer can understand by itself.
Your computer speaks only one language- machine code. Machine code is almost completely unreadable by human beings; it’s just a series of numbers. These numbers tell the processor and all the other internal hardware of the computer what to do. Machine code is entirely dependant upon the hardware to the computer, so different types of computer have different machine code languages. This is one reason why a Windows program won’t run on a Macintosh, and vice versa.
Programming languages, such as C and Java, were invented because trying to write computer programs in machine code is sheer madness. These languages allow programs to be written in a form which is far easier to read than a series of 1s and 0s. This is great for human beings, but not so great for the computer. Remember that by itself the computer can’t understand C, Java, or any other language other than its own machine code, so it needs a little help.
C is a compiled language. Since you are learning C, I guess that you know somthing about this. You write a source file, which is basically a text file containing your C code. Before your program can be run, it has to be sent through the C Compiler. The compiler is a program which reads through the source file that you’ve written, figures out what it means, and converts everything to machine code which can then be run on your computer. The machine code file usually comes with a “.exe” extension, meaning “executable”.
I should mention here that another bonus of using a programming language like C is that you can write a single program file which can be compiled on many different types of computer. A Windows .exe file can’t be run on a Macintosh, but if you recompile your .c source code using a mac compiler, you will generate a Macintosh program which functions basically the same as the PC version.
Following me so far? I really hope that I’ve written this up well…
There’s another type of programming language known as an interpreted language. This type of language does not require a compiler, and is never actually converted into machine code. Instead, you need a special utility called an Interpreter in order to run your program. The interpreter is kind of like a compiler: it loads your source file, and figures out what it means, but instead of converting the source into machine code the interpreter acts upon it immediately.
One of the troubles with interpreted languages is that anyone who wants to run your program needs to have the interpreter installed on their machine. Another trouble is that they are notoriously slow; when you run an .exe file generated by a compiled language, all that needs to happen is for the machine code to start doing its thing. When you run an interpreted language, the Interpreter needs to scan your program, figure out what it means, figure out how to implement it, check for errors, and eventually get around to doing whatever it is that you asked it to do.
Java is kind of an in-between case. It’s a compiled language, but it is compiled into the machine code for a “virtual machine”. This virtual machine isn’t hardware, it’s a software package: the Java runtime engine. So, the JRE is kind of like an interpreter for Java’s virtual machine code.
…
What makes a programming language a valid language? Why do they need to be so complex? Well, these things depend upon what purpose the language was created to fill. C was created as a general-purpose utility programming language, so it has to be pretty well capable of doing just about everything. Other languages are more specific in their roles, such as PostScript. This was a language developed by Adobe just to handle page formatting for printers and desktop publishing.
Why doesn’t someone write a general purpose language that mimics a spoken language? Well, for one, writing the compiler or interpreter for such a language would be sheer hell… no, seriously. I’m quite sure that this is one of the fifth circle punishments for evil math students…
Also, it seems to me that in a computer language, a designer would want to avoid such things as vagueness and ambiguity which are inevitable in human language. If I tell the computer to do something, then I want to be absolutely sure that it’s gonna do exactly what I said. Also, I want to be absolutely sure that what I told it to do is what I wanted to tell it to do. And I want the language to be exact enough that if in doubt I can check to see what the actual meaning of the stuff I told the computer to do is.
…
IMHO, C++ is a nasty and vile language. It is hideous in the same way as a bulldog… beguiling to some people, perhaps, but repulsive to others. If you’re just doing this for a hobby, I would reccomend learning Pascal first. A Pascal program looks much more like spoken English than a C program, and the language itself is less fricklesome. I use Pascal for most of my programming; a good (free) compiler can be found at http://www.freepascal.org.
Java is supposed to be a good choice. If you’re new to programming, you’ll probably have an easier time learning it than I have. I started programming back on the C64, and it’s been tough to bend my old habits around new paradigms, like OOP.
If you want the immediate power to create snazzy looking programs without having to tackle a steep learning curve, either Delphi or Visual Basic might be worth a look. If it’s games you want to program, check out the webpage for Blitz Basic. I’ve been playing around with the demo version for the past few nights. It allows you to write and run programs, but it won’t compile standalone executables.
I hope you’ve found this information either useful or interesting. And now it’s 2:30 in the morning. Good night…