Introduction to Language Translators / What are Language translators?

Language Translators:


Language Translators are the programs that translate high-level language program into machine code. Program written in any language is first analyzed by a special piece of software this piece of software is designed by the language designer. The software checks the program for errors optimizes the code and generates machine language for that program. All the software available for this purpose can be categorized into three main categories.

  1.  Assembler
  2. Compiler
  3.  Interpreter

 Assembler:

Assembler is a program that translates an assembly language program into machine code/Machine language.
In the early days of computers the programs had to be written in machine code instructions using binary codes. So writing programs was very difficult and time consuming task.
It was also prone to errors and removing these errors was another difficult task.
Assembly language was developed to make the job easier. Assembly language allowed the use of symbolic codes for machine instructions; these codes are called Mnemonics (pronounced as Ne-Monics). Obviously, writing programs in assembly language is much easier than writing instructions in binary. An assembly language provides one line of code for each machine instruction.

Compiler:

A compiler is a program that translates a source program (Some high level programming language) into machine code as a whole.
The generated machine code can be later executed. A compiler first reads the whole program before executing it.  The errors in the code are pointed out and then the machine language code is generated.  This output is known as object program. The object program executes very fast as it is directly understandable by the computer. Today most of the languages used compilers.  Once a program has been translated into machine code it can be loaded into machine and can be executed.  This process of translation is shown in the figure below.


As shown in the above figure, the high level program is called the source code and the translated program is called the object code.

Interpreter:

An interpreter looks at each line of the source program, decide what that line means, check it for possible errors and then execute that line. If one of the lines is executed repeatedly, it must be scanned and analyzed each time, greatly slowing down the solution of the problem at hand.  Thus interpreter execute code line by line.  If an error is encountered, the execution is stopped at that line and user is notified of the line where the error occurred. After the error has been removed, the user has to run the whole program from the beginning. This whole process slows down the performance of the interpreter as compared to the compiler. Most of the languages used for writing short scripts of code use interpreters.




Download Complete Topic in PDF Form.