Complier vs Interpreter
Both compilers and interpreters are the language processors used to convert
software codes written in high-level language into machine language codes.
Compilers and interpreters are types of system software. They are required
because a computer cannot process a code written in high-level programming
language like C, C++, Java, etc. Therefore, we convert a HLL code into machine
code for execution.
What is a Compiler?
A language processor that converts a program written in high-level language
into machine language, entire program at once, is called a compiler. Thus, the
input of a compiler is a high-level language code (called source code), while its
output is a machine language code (called object code).
A compiler scans whole program and then check it for syntactic and semantic
error, once the code is checked for errors, it is converted into an object code.
Then, it can be processed by the machine to perform the corresponding task.
The common programming languages that use compiler are C, C++, C#, etc.
What is an Interpreter?
A language translator that converts a high-level language program into a
machine language program, one line at a time, is referred to as an interpreter.
Interpreters converts the codes slower than compiler. This is because the
interpreter can scan and translate only one statement of the program at a
time. Therefore, interpreters convert the source code into machine code
during the execution of the program.
Interpreters do not generate an object code corresponding to the source code.
However, these are relatively easy to use and execute the code. The
programming languages that use interpreters are Perl, Ruby, Python, METLAB,
etc.
Parameter Compiler Interpreter
Program Compilers scan the entire The program is
scanning program in one go interpreted/translated one
line at a time
Error detection Errors are displayed in Errors are displayed in every
Compiler after Compiling single line.
together at the current
time.
Execution time Compiled codes run faster Interpreted codes run
than Interpreter. slower than Compiler.
Types of errors It can check syntactic and It checks syntactic errors
detected semantic errors in the only
program simultaneously
Efficiency Compilers are more Interpreters are less efficient
efficient.
Size Compilers are large in size Interpreters are small in size
Source code It does not require source code It requires source code for later
requirement for later execution. execution
CPU Utilization CPU utilization is more in the CPU utilization is less in the
case of a Compiler. case of a Interpreter.
Object code Convert the source code to Interpreters do not convert
object code source code into object code
Examples C, C++, C#, etc are Python, Ruby, Perl,
programming languages that SNOBOL, MATLAB, etc are
are compiler-based programming languages that
are interpreter-based