Compiler, Translator and Interpreter
Compiler:
A compiler is a program that translates a high-level language into a functionally equivalent low-level language.
Properties of Compiler:
- Compiler itself must be bug-free.
- It must generate correct machine code.
- The generated machine code must run fast.
- Compiler must be portable.
- it must give good diagnosis and error messages.
- The generated code must work well with existing debugger.
- it must have consistent optimization.
Translator:
A translator is a program that takes as input program, written in one programming language (Source language), and produce as output a program in another language(Target language).
if the source language is high level language such as C, FORTRAN and the target language is low level language such as machine language or assembly language then such translation is called compiler.
Interpreter:
An interpreter is a kind of translator which converts high level language into machine code.it translates one statement of high level language into machine code and then execute the resulting machine code and after that again translates the next instruction of high level language and execute it and so on. it never translates the whole program at a time.
Advantage:
- Modification of user program can be done easily.
- Debugging and finding errors can be done easily.
- overhead of program translation can be eliminated.
Disadvantage:
- Execution of a program is slower.
- Memory consumption is more.
Difference between Compiler and Interpreter:
|
S. No.
|
Compiler
|
Interpreter
|
|
1.
|
It is a complex program.
|
It is a easy program.
|
|
2.
|
It is difficult to write and
requires large memory in the computer.
|
It is easy to write and
requires large memory in the computer.
|
|
3.
|
Translates whole program
|
Translates program line-by-line
|
|
4.
|
Object code produced after translation.
|
No object code is produced.
|
|
5.
|
Not requires compiling a
program again and again.
|
It is necessary because no
object code is produced.
|
|
6.
|
Compiled program execute much
faster than interpreted program.
|
An interpreted program takes
more time in execution.
|


