As we know Machine Language is very ill-designed for human computer communication, so far the programmer it is very difficult to express his/her thought using machine language.
There are some advantages also written in high level language programs other than through machine language.
First of all it increases the productivity of the programmer that code can be written in easy way and more quickly.
Second thing, programmer is more concerned about the problem than the inner detail of the machine.
So, it increases the machine independence. But computer understands the machine language only.
Therefore, We need translators for the convenience of machine as well as the user.
Translator just converts each assembly language and high level language into corresponding machine language.
The input to translate the program is known as Source Language or Source Code.
Source Code might be assembly language or high level language.
The output of a translator is often called a machine language or target language.
Types of Translator:
There are three types of system software used for translating the code that a programmer writes into a form that the computer can execute (i.e. machine code).
Assembler is used to convert the program written in assembly language into machine language.
Advantages of using an Assembler:
§ Very fast in translating assembly language to machine code as 1 to 1 relationship.
§ Assembly code is often very efficient because it is a low level language.
§ Assembly code is fairly easy to understand due to the use of English-like mnemonics.
Disadvantages of using an Assembler:
§ Assembly language is written for a certain instruction set.
§ Lots of assembly code is needed to do simple tasks, and complex programs require lots of programming time.
Interpreter translates each source program statements into a sequence of machine language.
Interpreter translates the source program line by line that it would execute next line only when the first line has no error.
Advantages of using an Interpreter:
§ Easier to debug than a compiler
§ Easier to create multi-platform code, as each different platform would have an interpreter to run the same code.
§ Useful for prototyping software and testing basic program logic.
Disadvantages of using an Interpreter:
§ Source code is required for the program to be executed, and this source code can be read making it insecure
§ Interpreters are generally slower than compiled programs due to the per-line translation method.
A Compiler is a computer program that translates code written in a high level language to a lower level language.
The most common reason for translating source code is to create an executable program.
Advantages of using a Compiler:
§ Source code is not included; therefore compiled code is more secure than interpreted code.
§ Produces an executable file, and therefore the program can be run without need of the source code.
Disadvantages of using a Compiler:
§ Machine code needs to be produced before a final executable file, this can be a slow process.
§ The source code must be 100% correct for the executable file to be produced