Difference Between Compiler and Interpreter – Compiler Vs Interpreter
Difference Between Compiler And Interpreter
Compiler and interpreter both are used for the same purpose. But still, they have a difference between compiler and interpreter is given below.
Compilers and Interpreters both are the programming language translators which are used to translate program code written in a high level language into machine language.
The compiler converts high level language into machine code. While interpreter converts the high level language into intermediate code and it is executed by the processor.
The computer will not understand the high level language such as programming language is only understand by the human. It contains phrases and words in English or any other language.
The computer only understands the instruction in a binary format such as 0’s and 1’s. The binary code is known as machine language.
The program written in other programming language is called source code. The source code must be translated into the machine level language. This is done by compiler and interpreter.
The compiler is a unique program which translates a high level language into machine language that computer can understand.
Machine code produced by the compiler is saved in memory for future reference. It requires more computer memory for translate to machine code.
The compiler works fast in term of speed. And take less time for execution.
It checks all type of error, range, and limits. And it reports an error caused during the execution process.
If compiler runs on a computer and generates machine codes for another computer then this type of compiler is called cross compiler.
If compiler runs on a computer and generates machine codes for the same computer then this type of compiler is called self-compiler.
Example: C, C#, COBOL, etc.
The interpreter work same as a compiler but the difference is it convert the high level language into intermediate code. The intermediate code is executed by the processor.
It translates only one statement of the program at a time without considering the whole program at once. That means during the translation phase it read only one line of the program and translate it. And then read next line of the program.
Interpreter occupies less memory than compiler because of an interpreter is a small program than a compiler. So interpreter is used in a small application which has limited memory.
The machine code produced by the interpreter is not saved for future reference.
Example: VB, LISP, PostScript, etc.