Compiler Vs Interpreter
Compiler Vs Interpreter
Compiler Vs Interpreter
Definition of Compiler
A compiler is a program that reads a program written in the high-level
language and converts it into the machine or low-level language and
reports the errors present in the program. It converts the entire source
code in one go or could take multiple passes to do so, but at last, the user
gets the compiled code which is ready to execute.
Phases of Compiler
Definition of Interpreter
An interpreter may require processing the same syntax tree more than
once that is the reason why interpretation is comparatively slower than
executing the compiled program.
Key Differences Between Compiler and Interpreter
1. The compiler takes a program as a whole and translates it, but interpreter
translates a program statement by statement.
2. Intermediate code or target code is generated in case of a compiler. As
against interpreter doesn’t create intermediate code.
3. A compiler is comparatively faster than Interpreter as the compiler take the
whole program at one go whereas interpreters compile each line of code
after the other.
4. The compiler requires more memory than interpreter because of the
generation of object code.
5. Compiler presents all errors concurrently, and it’s difficult to detect the
errors in contrast interpreter display errors of each statement one by one,
and it’s easier to detect errors.
6. In compiler when an error occurs in the program, it stops its translation
and after removing error whole program is translated again. On the
contrary, when an error takes place in the interpreter, it prevents its
translation and after removing the error, translation resumes.
7. In a compiler, the process requires two steps in which firstly source code is
translated to target program then executed. While in Interpreter It’s a one-
step process in which Source code is compiled and executed at the same
time.
8. The compiler is used in programming languages like C, C++, C#, Scala,
etc. On the other Interpreter is employed in languages like PHP, Ruby,
Python, etc.
https://techdifferences.com/difference-between-compiler-and-interpreter.html
The compilation process in C