April 27, 2020

Difference between compiler and interpreter.

Compiler


The compiler translates a high-level language into a machine language. When a user writes code in a high-level language such as Java and wants to execute it, a special compiler developed for Java will be used before it can be done. The compiler first scans the entire program, and then translates it into machine code, which will be executed by the computer processor, after which the corresponding tasks will be performed.

Interpreter


Interpreters are not very different from compilers. They also convert high-level languages into machine-readable binary equivalents. Each time the interpreter receives high-level language code for execution, it converts this code to an intermediate language before converting it to machine code. Each part of the code is interpreted and executed separately and sequentially, and if an error is found in any part, it will stop code interpretation without translating the next part of the code.