Medium4 marksStructured
Computer systemsGeneraltranslatorsinterpreter

AQA GCSE · Question 07.2 · Computer systems

Explain how an interpreter works.

How to approach this question

Break down the process of interpretation. 1. What kind of code does it start with? (Source code) 2. How does it process the code? (Line by line, one statement at a time) 3. What does it do after translating a line? (Executes it immediately) 4. Does it produce a final, separate file? (No) 5. What happens when it finds an error? (Stops execution) Combine these points into a coherent explanation.

Full Answer

An interpreter is a program translator that works on high-level languages. It translates and executes the source code one statement at a time, line-by-line. It does not create a separate executable file. If an error is found on a line, the program stops running immediately at that point, which aids in debugging. Because it translates each line every time the program is run, execution is generally slower than with a compiled program.
An interpreter is a type of translator used for high-level programming languages. Its method of operation is distinct from a compiler. Here is a step-by-step explanation: 1. **Line-by-Line Translation:** The interpreter reads the source code one line or statement at a time. 2. **Immediate Execution:** As soon as it translates a single line into machine code, it immediately executes that code. 3. **Sequential Process:** It then moves to the next line, translates it, and executes it, continuing this process until the end of the program or until an error is encountered. 4. **No Executable File:** Unlike a compiler, an interpreter does not produce a standalone executable file of the entire program. The source code and the interpreter are needed every time the program is run. 5. **Error Handling:** If the interpreter finds an error on a line, it stops execution at that point and reports the error, which can make debugging easier as the exact location of the error is known.

Common mistakes

✗ Confusing an interpreter with a compiler (e.g., saying it creates an executable file or translates the whole program at once). ✗ Vague statements like "it interprets the code". ✗ Not providing enough distinct points to gain all the marks.

Practice the full AQA GCSE Computer Science Paper 2

46 questions · hints · full answers · grading

More questions from this exam