-->

Compiler vs interpreter

2 minute read

Compiler vs interpreter


Interpreter
Compiler
The interpreter takes one statement then translates it and executes it and then takes another statement.
the compiler translates the entire program in one go and then executes it.
interpreter will stop the translation after it gets the first error.
Compiler generates the error report after the translation of the entire page
interpreter takes lesser time in analyzing and processing the high level language code.
Compiler takes a larger amount of time in analyzing and processing the high level language code
overall execution time of a code is slower for interpreter.
overall execution time of a code is faster for compiler relative to the interpreter.
interpreter converts the high level instruction into an intermediate form.
A complier converts the high level instruction into machine language
interpreter is required by an interpreted program each time.
An independent executable file is created by the compiler

What is Compiler

compiler is a piece of code that translates the high level language into machine language. When a user writes a code in a high level language such as Java and wants it to execute, a specific compiler which is designed for Java is used before it will be executed. The compiler scans the entire program first and then translates it into machine code which will be executed by the computer processor and the corresponding tasks will be performed.  

Shown in the figure is basic outline of the compilation process, here program written in higher level language is known as source program and the converted one is called object program.

What is Interpreter in c

Interpreters are not much different than compilers. They also convert the high level language into machine readable binary equivalents. Each time when an interpreter gets a high level language code to be executed, it converts the code into an intermediate code before converting it into the machine code. Each part of the code is interpreted and then execute separately in a sequence and an error is found in a part of the code it will stop the interpretation of the code without translating the next set of the codes.  

Outlining the basic working of the interpreter the above figure shows that first a source code is converted to an intermediate form and then that is executed by the interpreter.