What is The Difference Between Interpreter and Compiler



A compiler is a kind of translator that translates a program into another program, known as target language. Usually, the term compiler is used for language translator of high level language into machine language. The compiler replaces single high-level statement with a series of machine language instruction. A compiler usually resides on a disk or other storage media. When a program is to be compiled, its compiler is loaded into main memory. The compiler stores the entire high-level program, scans it and translates the whole program into an equivalent machine language program. During the translation process, the compiler reads the source program and checks the syntax (grammatical) errors. If there is any error, the compiler generates an error message, which is usually displayed on the screen. In case of errors, the compiler will not create the object code until all the errors are rectifies.
Once the program has been compiled, the resulting machine code is saved in an executable file, which can be run on its own at any time. To be precise, once the executable is generated, there is no need for the actual source code file. Anyway, it is worthwhile to keep the source files because if the source code is modified. It is necessary to recompile the program again to regenerate the executable file containing amendments.



Unlike compilers, an interpreter translates a statement is a program and executes the statement immediately, before translating the next source language statement. When an error is encountered in the program, the execution of the program is halted and an error message is displayed. Similar to compilers, every interpreted language such as BASIC and LISP has its own interpreters.

Difference between interpreter and compiler

It translates one instructions at a time.
Translates whole high level language program into machine language at time.
Interpreter do not generate object program on the disk.
Compiler generates object program on the disk.
If any error is found, at any instruction, it stops translation and displays error message immediately.
Display list of syntax errors, with line numbers, at the end of the compilation process.
Interpreters are user friendly and hence easy to use.
Compiler are not user friendly hence not easy to use.
It requires less space in the memory.
Requires more space in the memory.
They are used in the program development stage since they are interactive.
They are used after the program development is complete.
You need interpreter each time when you want to run the source program.
Object code can run any no. of times and on any machine without compiler.
Execution is slow, because each time it will do translation.
Execution of object program is fast.

Free Mock Tests Are Available Here

Scroll to Top
Scroll to Top