Monday, July 8, 2019

Translators


Translators:
They have an important role to play in the execution of programs. We know that computer understands only machine language of 0s & 1s . But the coding of high level language use english commands. So we need someone to translate the code to the machine specific code,This is the task of a translator.

A computer program that translate a program written in any language into its equivalnt byte code or machine code is known as a translator. It can be categorized as:

  1.   Assembler
  2. Compiler
  3. Interpreter



Assembler:
It is a program that converts the instruction into bits for the understanding of computer. It acts upon each statement of source code & converts it into the corresponding bits. It also converts decimal numbers into binary code. It genrates object code which is also known as machine code. This machine code once genrated can be executed as and when desired. The genrated code contains a combination of machine instructions, data & all the desired information about placing the instruction in the memory.

Compiler:
It is a progarm that translate the code written in language like C, Java, C#, etc into a byte code or machine code (CPU specific) so that the computer can understand. It first checks the code for any errors. If ther are errors, it reports all of them to the programmer. But if the code is free from errors,the code is converted to its equivalent byte code or machine code. Compled code is faster to execute. The executable code created by compiler can be executed anywhere & anytime without requring recomplilation.

Interpreter:
It reads the code fed to it line by line. If the line being read is free from any error, the code is converted to executable code and then executed. If there is any error, interpreter stops ther itself and reports the error to the programmer. Some languages like java have both compiler and interpreter. Compiler converts source code to byte code. The byte code Is machine independent, so it is portable. The interpreter converts byte code into the machine specific code line by line and execute it.

Thanks for reading.......

0 comments: