Tuesday 3 November 2020

Differences between Compiler and Interpreter (Compiler vs. Interpreter)

 Compiler vs. Interpreter :

Compiler

Interpreter

Compiler works on the complete program at once. It takes the entire program as input.

Interpreter works line-by-line. It takes one statement at a time as input.

Compiler generates intermediate code, called the object code or machine code.

Interpreter does not generate Intermediate object code or machine code.

Compiler executes conditional control statements (like if-else and switch-case) and logical constructs faster than interpreter.

Interpreter executes conditional control statements at a much slower speed.

Compiled programs take more memory because the entire object code has to reside in memory.

Interpreter does not generate intermediate object code. As a result, interpreted programs are more memory efficient.

Compile once and run anytime. Compiled program does not need to be compiled every time.

Interpreted programs are interpreted line-by-line every time they are run.

Errors are reported after the entire program is checked for syntactical and other errors.

Error is reported as soon as the first error is encountered. Rest of the program will not be checked until the existing error is removed.

A compiled language is more difficult to debug.

Debugging is easy because an interpreter stops and reports error as it encounters them.

Compiler does not allow a program to run until it is completely error-free.

Interpreter runs the program from first line and stops execution only if it encounters an error.

Compiled languages are more efficient but difficult to debug.

Interpreted languages are less efficient but easier to debug. This makes such languages an ideal choice for new students.

Examples of programming languages that use compilers: C, C++, COBOL

Examples of programming languages that use

interpreters: BASIC, Visual Basic, Python, Ruby, PHP, Perl, MATLAB, Lisp

No comments:

Post a Comment