Language Translators
Language Translators
Programs written in assembly language is translated into machine code by the assembler.
Each instruction in the source code consists of opcode and operand.
The software translates low level language into machine code for the processor to execute.
The source code uses instructions from the processor’s instruction set.
Explain the benefits and drawbacks of using either a
compiler or interpreter and justify the use of each
Explain the benefits and drawbacks of using either a compiler or interpreter and justify the use of
each
Compiler translates high level language into machine code for the processor to execute.
Compiler executes an executable file.
No need to give access to source code so makes it more difficult for the user to modify the code.
Benefits of compiler:
produces an executable file.
User does not have access to source code.
It will probably be faster to run the executable file.
Code does not have to compiled each time it is executed.
Does not need the compiler to be present at runtime.
Drawbacks of compiler:
The source code must be re compiled every time the programmer changes the program.
Finding errors is difficult as error messages are given at the end.
The source code must be 100% correct for executable file to be produced.
interpreter translates high level language into machine code for the processor to execute line by
line.
Th interpreter reads each statement and checks it before running it.
The interpreter halts when it encounters an error.
The interpreter analyses and checks each line before executing it.
Benefits of interpreter:
Drawbacks of interpreter:
Compilers create an executable file. Interpreter does not create executable files.
The compiled program can be independently distributed but interpreted program cannot be
executed without interpreter.
The interpreter executes each statement immediately after decoding. Compiler checks the
whole program for errors.
The interpreter software must be present in main memory every time the program is executed.
The compiled program does not require a compiler.
Cross compilation is possible (compile on one hardware to run on another)
See the table from hooder books page:152
Show awareness that high-level language programs may be partially compiled and partially
interpreted, such as Java (console mode):