Interpreter vs Compiler: 

While they are similar, the Compiler scans the whole program and translates the whole program to machine code. The Interpreter performs the actions described by the program one by one, therefore it has to translate the code every time a statement is executed.

Generally, the compiled program runs much faster, due to compiler usually has optimisation feature, while the interpreted program runs slower. Also the compiled program doesn’t have to compile again as the object code is generated once, while interpreted program does not have any code generated.

One thing that Interpreted may be better than Compiled program is memory requirement (less memory required).

Dynamic Compilation:

There are many optimisations that can only be done at run-time, the compilation alone is not able to perform them, therefore the dynamic compiler will compile the code first, and will optimise even more at run-time. Once the program has run for a few minutes, the dynamic compiler will optimise it again so that the program becomes faster.

Java is a language using this technique. Compiling once, usually to IF (intermediate format) and then compile again in run-time to machine code.

Just-in-time compilation is a form of dynamic compilations. It combines the benefits of compilation speed with interpretation’s flexibility. It is a technique used for Dynamic programming languages

Incremental compilation is a closely related technique but  it doesn’t change the speed of a program at run-time like dynamic compilation.

Advertisements