Cambridge O Level Computer Science · Syllabus 2210 · Software
Interpreter
What is Interpreter?
An interpreter is a translator that translates and executes a high-level language program line by line. It stops execution when it finds an error and reports it at that statement, and it produces no executable file, so the source code must be translated again each time the program runs.
This definition is part of the Software chapter in Cambridge O Level Computer Science.
Interpreter in context
A computer is built in layers, and each layer only works because the layer beneath it is already running. Hardware executes machine instructions and nothing else. Firmware, held in non-volatile memory, starts the hardware and its bootloader loads the operating system. The operating system then manages files, memory, peripherals, users and security, and provides the platform on which application software runs. While all of that is happening, interrupts let an urgent event — a key press, a division by zero — reach the CPU without it having to keep asking. And because a CPU can only execute machine code, every program a person writes must first be put through a translator: an assembler, a compiler or an interpreter.
An interpreter translates and executes a high-level program line by line. It translates one statement, executes that statement, then moves to the next, and it stops execution when it finds an error — reporting the error at the statement where it occurred. Because it works statement by statement, an interpreter produces no executable file: the source code must be translated again every time the program is run.
Every difference between a compiler and an interpreter follows from one thing: how much is translated before anything is executed. A compiler translates the whole program first and produces an executable file; an interpreter translates and executes line by line and produces none. From that single difference come the error behaviour, the speed, the distribution options and the reason that, in practice, an interpreter is mostly used while a program is being developed and a compiler is used to translate the final program.
Common mistakes with Interpreter
- 6. Making the compiler line-by-line, or the interpreter whole-program. Why it fails These are exactly the wrong way round, and swapping them makes every other difference in 4.2 come out backwards too. A compiler translates the whole code before it is executed and produces an executable file. An interpreter translates and executes line by line and stops when it meets an error. Fix Memorise the pair as a single sentence, in that order, and never write one without the other. See the translator laboratory.
- "An assembler translates a high-level language." Correct model An assembler translates assembly language into machine code. High-level languages are translated by a compiler or an interpreter. Exam-safe sentence "An assembler is needed to translate an assembly language program into machine code."
- M12. "High-level code is directly executed by the CPU." Why it fails If it were true there would be no reason for compilers, interpreters or assemblers to exist — and the whole of 4.2 would be unexplainable. Corrected model A CPU executes machine code and nothing else. High-level source must be translated into machine code by a compiler or an interpreter first. Exam-safe sentence "High-level language must be translated into machine code before the CPU can execute it." Show the retrieval checkHide the check Check: What is the only kind of code a CPU can execute?Answer: Machine code — binary instructions from its own instruction set.
- M15. "An assembler translates high-level code." Why it fails It names the wrong translator, which is a direct loss of a mark in any question that asks which translator is needed. Corrected model An assembler translates assembly language into machine code. A compiler or an interpreter translates a high-level language. Exam-safe sentence "An assembler is needed to translate an assembly language program into machine code; high-level languages are translated by a compiler or an interpreter." Show the retrieval checkHide the check Check: Match each translator to what it translates: assembler, compiler, interpreter.Answer: Assembler → assembly language. Compiler → a whole high-level program. Interpreter → a high-level program, line by line.
- M16. "A compiler translates and executes one line at a time." Why it fails This is the interpreter's behaviour attached to the wrong name. It also makes the compiler's error report and its executable file impossible to explain. Corrected model A compiler translates the whole program at once, before it is executed, and produces an executable file. Exam-safe sentence "A compiler translates the whole code at once before executing it, producing an executable file." Show the retrieval checkHide the check Check: A 500-line program has an error on line 40. How many lines does a compiler execute?Answer: None. Nothing is executed until the whole program has translated successfully.
- M17. "An interpreter translates the entire program first." Why it fails It is the compiler's behaviour under the wrong name, and it contradicts the interpreter's own error behaviour: if it translated everything first, it could not stop at the first error it reached. Corrected model An interpreter translates and executes the code line by line: one statement is translated, then executed, then the next. Exam-safe sentence "An interpreter translates and executes the code line by line." Show the retrieval checkHide the check Check: A 500-line program has errors on lines 40 and 310. How many errors does an interpreter report on one run?Answer: One — the error at line 40. Execution stops there, so line 310 is never reached.
- M18. "An interpreter creates a standalone executable." Why it fails It removes the interpreter's defining disadvantage. If an executable existed, the source would not need translating on every run. Corrected model An interpreter produces no executable file. In the simplified syllabus model, the source code and a suitable interpreter are both needed wherever the program is to run. Exam-safe sentence "An interpreter does not produce an executable file, so the source code is translated again every time the program is run." Show the retrieval checkHide the check Check: Why can a company not distribute an interpreted program without giving away its source code?Answer: Because no executable is produced — the interpreter needs the source in order to translate and run it each time.
- M20. "An IDE is a programming language." Why it fails It confuses the tool with the material. You write a language in an IDE, and the same IDE often supports several languages. Corrected model An IDE is software that combines the tools needed to develop programs — editor, run-time environment, translators, error diagnostics, auto-completion, auto-correction and prettyprint. It is also not itself the translator; it calls one. Exam-safe sentence "An IDE is software that combines the tools used to write, translate, run and correct programs into one application." Show the retrieval checkHide the check Check: Is the translator part of the IDE, or something the IDE uses?Answer: Something the IDE contains and calls. The translator remains a compiler or an interpreter in its own right.
Examiner tips on Interpreter
- The one-line test. If a question mentions mnemonics, the answer is an assembler. If it mentions an executable file or distribution, the answer is a compiler. If it mentions testing while writing or stopping at an error, the answer is an interpreter.
Questions students ask about Interpreter
What is the difference between a compiler and an interpreter?
A compiler translates the whole of a high-level program at once, before any of it is executed, producing an executable file and a single error report covering the whole program. An interpreter translates and executes a program line by line, stopping and reporting an error at the exact statement where it occurs, and produces no executable file, so the source code must be translated again every time the program runs. An interpreter is mostly used while a program is being developed; a compiler is used to translate the finished program.

