Language Translators
The computer understands only binary language. It does not understand other high-level languages like English. All the instructions written in high-level languages are first converted or translated into machine language. Special programs (system software) called language translators or language processors are available to do this job. These special programs accept the user programs (source code) and check each statement and, if grammatically or syntactically correct, produce a corresponding set of machine language instructions (object code).
There are three types of translators.
1. Compilers 2. Interpreters. 3. Assembler
COMPILER
System software that checks the entire user written program (source code) and if error free, produces a complete program in machine language (object code). If errors are encountered in the source code then a list of errors is displayed on the screen with their respective contexts. The source code is retained for possible modifications and corrections and object code is loaded into the memory for execution.
INTERPRETER
System software that does a similar job (as compiler), but in a different style. It translates one statement at a time and, if error free, executes the instruction. This continues till the last statement in the program has been translated and executed or an error is not encountered.
INTERPRETER V/S COMPILER:
- Error correction (debugging) is much simpler in case of an interpreter because it is done in stages (step-by-step). On the other hand the debugging is complex in case compiler because it produces an error list for entire program before execution.
- Interpreter takes more time for the execution of a program. In contrast, compiler translates the entire program at a time so consumes leaser time in program execution compared to interpreter.
- Interpreter reads each line of source code one by one, translates it into machine code and also gets it executed but compiler first scans the entire source code for errors, and if the source code is error free, it translates each line of the source code into it's equivalent machine code and saves the translated version into a separate file called object code.
- Interpreter based programs occupy more space in RAM during execution, because the source code as well as the interpreter program must reside in the memory but compiler base programs occupy less space in RAM during execution, because the translated version of the source code is already available and can be executed directly without the aid of any software.
- Source code is not safe because it is required every time the program is run but in compiler the source code is safe because it is not required once the translated version is ready.
- Certain erroneous statement may escape detection, because the interpreter checks only those statements for errors that it executes but No error can escape the eye of the compiler.
- Interpreter based programs occupy less space on disk but compiler based programs occupy more space on disk.
ASSEMBLER
A computer will not understand any program written in a language other than its machine language. Hence, the programs written in other languages must be translated into the machine language of the computer before they are executed. Such translation is performed with the help of another software. A program, which translates an assembly language program into a machine language program, is called an assembler. An assembler that runs on a computer for which it produces object codes (machine codes) is called a self-assembler (or resident assembler). Assembler uses mnemonic symbols that can be easily translated into machine codes.
COMPILATION
The program, which is written in the English like language that is converted into the machine language using the compiler. The process of converting the high-level language program into the machine language program or we can say that in binary form as 0 or1 format is called the compilation.
Note:
Compiling the program we press Alt+F9 key.
Running the program we press Ctrl+F9 key.
To save the program we press F2 key.
To see the output screen we press F5 key after compiling and running the program.