Language processor is a type of software that is used to translate a program from a high-level language into a low-level language. Because computer only understands the program written in the low-level language. Let’s read further for more information.
The computer understands only machine language. A computer cannot directly execute a program written in high level or assembly language. Before execution, the program must be converted into machine language. Language processor or translators is a software that converts these programs into machine languages. Every computer language has its own translators also.
Types of Language Processor
Different types of language processors are as follows:
A compiler is a program that converts the instructions of high-level language into machine language as a whole. A high-level language program is called a source program. Compiler converts source program into machine code. This machine code is known as an object program.
Furthermore, The compiler verifies every statement in the source program and produces machine instructions. Syntax errors in the program are also checked by the compiler. A source program containing an error cannot be compiled.
A compiler translates the programs of only that language for which it is written. For example, the 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 at one time. Before translating the next statement of the source program, It executes this statement first. if there is an error in the statements, the interpreter stops working and displays the error message.
Furthermore, the advantages of interpreters over compilers are that an error is found immediately. so the programmer can correct errors during program development.
The drawback of an interpreter is that it is not very competent. The interpreter does not generate an object program. It must convert the program each time it is executed. Visual Basic also uses an interpreter.
An assembler is translating program that converts assembly language programs into machine language.
Difference between Compiler and Interpreter
Following is a brief difference between compiler and interpreter:
|The compiler converts a program into machine code as a whole||Interpreter converts the program into machine code statement by statement|
|The compiler creates object code file||Interpreter does not create object code file|
|A compiler converts a high-level program that can be executed many times||An interpreter converts high-level program each time it is executed.|
|Programs execution is fast||Programs execution is slow|
|Compiler displays syntax errors after compiling the whole program||Interpreter displays syntax error on each statement of program|
Relationship of Object Program, Source Program, and Compiler
A source program is written by a programmer in a programming language such as C. This program is not in a form that a computer can understand. A compiler translates the source program into the object program that the computer can understand and execute.