Computer understand only machine language. A program written in high-level or assembly language cannot be run on a computer directly. It must be converted into machine language before execution. Language processor or translator is a type of system software that programs into machine language. Every computer language has its own translator.
Types of Translators
Different types of translators or language processors are as follows
A compiler is a program that converts the instruction of a high level language into machine language as a whole. A program written in high-level language is called source program. The compiler converts the source program into machine code. The machine code is known as object program. The object program can be executed many times
The compiler checks each statement in the source program and generates machine instructions. compiler also checks syntax errors in program . A source program containing an error cannot be compiled.
A compiler can translate the programs of only those languages for which it is written For example, C compiler can translate only those programs that are written in C language.
An interpreter is a program that converts one statement of a program into machine at one time. It executes a statement before translating the next statement of the source program. It there is an error in the statement, the interpreter stops working and displays the error message.
The advantage of interpreters over compilers is that an error is found immediately The programmer can correct the errors during program development.
The disadvantage of interpreter is that it is not very efficient. The interpreter does not produce an object program. It converts the instructions into machine language each time it is executed. BASIC language uses interpreter.
An assembler is a translating program that translates the instruction of assembly language into machine language.
The difference between compiler and interpreter is as follows:
|1. The compiler converts the entire source code into machine code.||1. The Interpreter converts one instruction into machine code.|
|2. It generates object code.||2. It does not generate object code.|
|3. The program execution is fast.||3. The program execution is slow.|
|4. It converts high-level program that can be executed many times.||4. It converts high-level program each time it is executed.|
|5. It displays syntax error after compiling the whole program.||5. It displays the syntax error on each instruction of the program.|