The role of Assemblers, Interpreters, and Compilers
A computer will not understand any program written in a language which is any other besides machine code. Therefore these other languages must be translated in order for them to be understood and run by the computer.
An assembler is a piece of software that translates assembly language, one that is very basic but not yet machine, into machine code - binary.
A compiler is another program which translates a high level language into machine code. A compiler's run time is very slow and occupies a large amount of memory, this is due to the fact that the entire program is translated into machine code before running. Eventually, over time, on a large developing program, because every small change means the entire program must be re-compiled, the run time will be high. Every time a program is compiled, object code is produced, which can be executed directly by the computer, and is distributed in this form. The bugs detected will be presented to the programmer after the program has been compiled, which is less efficient than an interpreter.
The last type of translator is an interpreter, which translates the program line-by-line, into a machine code version also known as object code. It reads one line of assembly code made up of mnemonics (a language which has a very strong connection with machine code as it is essentially machine code with words), translates, and executes. The number of words accessible in assembly language is limited, however each command translates directly to one line of machine code - one to one relationship. Interpreters make it very easy to debug as the program will run until a bug is met, producing an error message that helps the user to debug the program. However, they re-translate the same line of code over and over again into source code, perhaps increasing the overall run time.
The difference between compilation and interpretation
There is no difference between 'compiled programming language' and 'interpreted programming language', therefore interpretation and compilation are implementation techniques.
Compilation is achieved through the use of a compiler, where a program written in source code is translated to object code. Simultaneously, the compiler may attempt to transform the program in way that will make the program faster - without altering the programs purpose.
Interpretation is achieved through the use of an interpreter. whereby it performs operations on behalf of the program being interpreted in order to run it.
Situations where interpretation and compilation would be appropriate
Interpretation would be appropriate if the programmer is fairly new to the concept of programming, this is because interpreters are easy to write and present clear errors with error lines for the programmer to alter.
Compilation would be appropriate if the code was being distributed and edited among many programmers all working on the same code. This is because compilation produces object code that is executable on any instruction set.
Intermediate languages as the final output by some compilers
Bytecode/object code is frequently the product of compilation as it is a form of the source code that is executable on any computer using a virtual machine.
Source and object code
Source code is the format by which a list of commands are written to be compiled or assembled into an executable computer program.
Object code on the other hand is executable code that is produced by both a compiler and assembler.