A compiler in it's simplest form is a translator program that takes in source code (high level language) as input and converts that to machine code (binary objects). The compiler converts the entire program source code at compile-time.
An interpreter on the other hand is a translator program which emulates the behavior of a program in execution. It converts the program source code by evaluating one line at a time.
The table below highlights the key differences between a compiler and an interpreter.
Comparison Chart - Compiler vs Interpreter
|Generates intermediate object code||No intermediate object code produced|
|The compiler takes an entire program for evaluation||The interpreter takes one line of the program at a time for evaluation|
|Compilation is done before program execution||Compilation and program execution happen at the same time|
|Compilation process is faster||Slower compilation process|
|More memory is needed to create intermediate object code||It requires less memory as no intermediate object code is needed|
|Detecting errors is difficult||Easier to detect errors|
|C++, C and C# are compiled languages||PHP, Perl, Python, Ruby are interpreted languages|
|All errors after compilation are displayed at the same time||Errors are displayed one after the other; line by line.|