Holy ****

Programming with Interpreters and Compilers

Assembly Language started the ball rolling. A computer program had been created to make the job of creating a machine language program simpler. This process could be continued and a more sophisticated program could translate a program that is very similar to human language. One person, who must be mentioned, is the late Grace Hopper. Grace Hopper was a lieutenant in the Navy when she first worked extensively with computers. She was largely instrumental for developing translating programs that allow programming in a human-style language. She was one of the main developers of the popular program language, COBOL, and was very influential in the development of early translators.

Two types of translating programs were created, interpreters and compilers. An interpreter takes a program and translates the program one line at a time. After each line is translated, the resulting machine code is executed. A compiler translates the entire program into a machine code file and then executes the file. It is easier to create an interpreter, but the execution speed is slower than a compiler. A compiler is far more complex to create, but it executes much faster than an interpreter. The majority of today’s program languages use compilers for translators. The language you will learn, Java, oddly enough is both a compiled and an interpretive language. How this is possible will be explained soon.


Low-Level and High-Level Program Languages

Languages that are very close to computer binary code are called low-level. Machine code and Assembly Language are low-level languages. Languages that are closer to human languages are called high-level languages. Some languages are very high-level today, and many programming tasks have already been performed. With many languages, it is possible to click and drag on program objects that have already been created and insert them inside your program.

So why not simply write your programs in English? Is that not a matter of creating some kind of translating program that takes English instructions and creates a machine code file for the computer? This is certainly what has been attempted for many years, but translating human languages has been very elusive. Consider the following example. In the sixties, computer scientists tried to write a program that would translate English into Russian and Russian into English. This is really the same problem of properly understanding the meaning of human language. The scientists decided to test their program by entering an English sentence. The resulting Russian sentence was then entered back into the computer and the final result should be the original English sentence. Should, that is, if the computer could translate correctly in both directions. The original sentence entered was:

The spirit is willing but the flesh is weak

I do not have a clue what the Russian result was, but I do know the final English result. Our computer scientists were quite surprised with

The Vodka is great but the meat is rotten


This little experiment showed the major problem with human languages. Human languages like English are idiomatic. We use all these idioms and proverbs, and slang and special nuances that are meaningless to the computers. How can computers figure out human language, when humans are confused?
The bottom line is that programming requires a restricted language. This language can have human type words, but the words selected, the symbols and punctuation used, all must have a very precise meaning. The manner in which the program language structures its statements is called syntax. Program languages must have very precise syntax. Compilers first check to see if a program has correct syntax. Only after the syntax checks out, is the next step of translating into binary code performed.

Source Exposure Java Part I by Leon Schram