(Ref Capron Ch 12)
Computer programming is considered to be a very difficult task. This became very obvious not long after the first computers were inventented. Computer programs are very complex, requiring many different things to be dealt with at the same time. It is considered that computer programs are some of the most complex things ever built. The programming of the early computers was difficult, tedious and error prone and it had to be done without the aid of software tools.
Eventually, the use of nmemonics and assemblers made life a little easier for programmers. However, for each new computer, a new set of instructions needed to be learnt.
Interpreter
The concept of writing pseudocode (instructions writen at a higher level to machine code) and having the computer interpret this was first thought of in 1951. This idea quickly took off and was used in many systems. The most significant consequence of these interpreters is that they implemented a virtual computer and removed the complexity of the real machine.
However, interpreters made the computers run a lot slower (a factor of 10) but that was considered acceptable as it made the work of the programmer a lot easier and a lot less complex.
Although early interpreters were only used to help with the more complex parts of the computer program, with the introduction of non machine specific languages such as BASIC, they are now used to interpret the entire program.
Modern interpreters will take one line of a computer program, convert it into machine language and then pass that onto the processor for processing. If there is an error, the interpreter stops and will not proceed past that line until the error is fixed.
The advantage is
The disadvantages are
Compiler
Grace Hopper (inventer of COBOL) and others, back in the 1950's also tried an alternate approach in which larges pieces of pseudo-code were converted, in one process, to machine code just before the program was to run, and then used the converted code. This eliminated the overhead of interpretation.
Unlike an interpreter, a compiler takes the entire code of a program and tries to convert it into machine equivalent code. That means that when the program is running, it is only doing one thing - running machine code to do the required job.
The advantages are
The disadvantage is
Early compilers would just list all of the errors found. Quite often, this resulted in many pages of errors as one error would cause many other errors to appear to be present. However, modern compilers, like the Borland Pascal compiler, flag the first error and stops allowing the errors to be fixed one at a time.
Modern systems
The systems currently used today, such as Visual Basic, have the best parts of both systems. In the development stage of a VB program, the systems acts as an interpreter. Using the debug facility, the program can be interpreted one line at a time - the programmer can step through the program. When it is error free and ready for publication, it is compiled into the native language of the computer and then distributed.
(Ref: Principles of Programming Languages, MacLennan BJ)
Author Mike Leishman