4.6.3.1 Types of program translator Flashcards
How does an interpreter work?
Analyses the code line by line and translates each statement if the line is error free. It calls the appropriate routines to carry out the statement.
What’s the difference between a compiler and interpreter?
A compiler produces object code but an interpreter doesn’t
Interpreted code will execute slower than the object code produced by the compiler
The interpreter is required to translate the program but once the compiler produces object code it is no longer needed.
Compiled code can only be executed on that processor type whereas an interpreter is more portable
When would you use a compiler?
When you need to execute the program faster. It is useful when distributing software as once the object code is produced it can’t be tampered with by the user. It is used when development of the program is finished.
When would you use an interpreter?
When you need to debug and test your program as correcting mistakes will take less time
What has to be done to assembly code to allow it to be executed by the computer?
It has to be translated into machine code by an assembler
Why is bytecode produced by some compilers?
Bytecode is an intermediate code (i.e. it is between source code and object code). Source code is translated in to bytecode, which can be run on a virtual machine. A virtual machine translates bytecode into the appropriate instruction code.
What is the difference between source and
object (executable) code
object code: The code produced by a compiler.
source code: consists of instructions in a particular language. programming code that has not been compiled yet
Describe how interpreter software enables a program written in a high level language to be executed.
The interpreter software is resident in memory at the same time as the application program is run;
The interpreter translates each statement
if ‘error free’ the statement /line is executed;
The interpreter calls a procedure/code to execute the statement;
When (first) error encountered program execution is halted;