Thursday, December 3, 2009

Difference between compiler and Interpretor.

Interpreter
An interpreter reads the source code one instruction (a line) at a time, converts this line into machine code and executes it. The current machine code is then discarded and the next line is read. Examples of interpreters are Basic and script interpreters such as Tcl script, JavaScript etc.

Advantages
The advantage of this is it's simple and you can interrupt it while it is running, change the program and either continue or start again.

Disadvantages

Every line has to be translated every time it is executed, because of this interpreters is relatively slow.

Compiler
A compiler reads the whole source code and translates it into a complete machine code output as a new file(object file). This completely separates the source code from the executable file. Examples of compilers are Visual Basic, C, C++, C#, Fortran, Cobol, Ada, Pascal etc.

Advantages
Advantage of this is that the translation is done once only and as a separate process. The program that is run is already translated into machine code so is much faster in execution.

Disadvantages
The disadvantage is that you cannot change the program without going back to the original source code, editing that and recompiling.

No comments:

Post a Comment

Search Ranjeet's Blog