What is a Translator?
A translator is a utility software which converts a source code written in programming language, by a programmer, into executable machine code. Translator takes source code as input and convert it into target language (i.e. machine language) as output. A translator is also known as programming language processor.
Source code
A source code is a set of instructions and commands written by a programmer using a programming language. Basically, source code is the set of instructions written in a programming language to give commands to computer, which is converted by a translator into executable machine code for processing.
Object code
The executable machine code, that has been translated from a programming language, with the help of a translator, is called object code.
Types of Translators
There are three types of Translators:
- Assembler
- Interpreter
- Compiler
Assembler
An assembler is a utility software which converts source code written in assembly language into executable machine code, i.e., object code. An assembler serves as a bridge between symbolically coded instructions written in assembly language and the computer system.
Interpreter
An interpreter is a utility software which converts source code written in high level language into low level language, i.e., machine language. It converts source code into executable machine code line by line and directly executes the code. This means that it does not create object code, but, instead, it directly executes the code while converting it. This makes the execution of the programs faster, but only if program is small. It can be time-consuming if the program is long. So, interpreters are sometimes used to quickly test small sections of a program.
Some of the programming languages that use interpreter are BASIC and LISP.
Compiler
A compiler is a utility software that converts source code written in high level language into low level language, i.e., machine language. It converts source code into object code, at once (not line by line), which is then executed. This process takes some time, which makes the compiler's working slow, but, this is only true for small programs. If program is long then compiler executes it much faster than interpreter. Most of the high level languages use compilers. Some of them are, C, C++, etc.