A high-level program must be translated into machine code before it can be run.
Describe how a compiler and an interpreter differ in when the translated code is executed.
Mark scheme
Award up to two marks for a linked description such as:
- The interpreter executes each line as soon as it has been translated (1) so translation and execution happen together/at the same time (1)
- The compiler translates the whole program first (1) and the machine code is run later/separately (1)
- The interpreter translates the code and runs it while the program is running (1) whereas the compiler does not run the code it produces (1)
- The compiler produces translated code that is executed only after all the translation has finished (1) but the interpreter executes each line immediately (1)
Allow 'translates one line at a time' where it is linked to executing each line immediately.
Do not accept answers that only state that a compiler is faster/an interpreter is slower, without reference to when execution happens.
Do not accept answers that only give object code, error reporting or portability, without reference to when execution happens.
Do not accept the compiler executing the program as it translates it.
Example answers and how they were marked
The compiler translates the code first and the program is executed afterwards, but the interpreter executes each line as soon as it has been translated.
Why: Compiler translates the whole program first and it is executed afterwards (1) and interpreter executes each line as soon as it is translated (1).
The interpreter executes each line immediately after translating it.
Why: Correct interpreter timing (1); no comparison with when the compiler's translated code is executed.
The compiler executes the program line by line as it translates it.
Why: Reverses the two translators; a compiler does not execute the program it translates, so no mark.