What is difference between Compiler and Interpreter

- May 10, 2018
A language translator program that translates the complete source code into machine code as a whole is called compiler. While, a language translator program that translates source code into machine code statement by statement is known as Interpreter.
The main differences between compiler and interpreter are given below:
Compiler Interpreter
It provides fastest program execution. Program execution is slow.
Translator program is not required to translate the program each time we need to run the program. Translator program is required to translate the program each time we need to run the program.
It's difficult to detect and correct the errors in the source code. It is easier to correct the errors in the source code.
It creates an object file. It doesn't create an object file.
Most of the high level programming languages have compiler program. A few high level programming languages have interpreter program.
pictorial form of compiler and interpreter

How does Compiler work?

The program translated into machine code is called object code. The source code is translated into object code successfully if it's free of errors. If there is any error in the program, then compiler specifies the errors at the end of compilation. The errors must be removed before the compiler can successfully compile the code. The object program can be executed a number of times without translating it again and again.

How does Interpreter work?

The interpreter translates one statement of source code into machine code and executes it immediately before translating the next statement. If there is error in the statement, the interpreter terminates its translating process at that statement with an error message.