x

Revision notes for Edexcel GCSE Computer Science Interpreters versus compilers. Open the guide for explanations and worked examples. Written against the Edexcel GCSE Computer Science (1CP2) specification, so the content matches what's examinable rather than general Computer Science background.

Interpreters versus compilers

What you'll learn

  • Why high-level code must be translated before the CPU can run it.
  • What a compiler does when it translates a program.
  • What an interpreter does when it translates a program.
  • How to compare compilers and interpreters in GCSE exam answers.

The prerequisite: programs must become machine code

When you write a program in a language such as Python, Java, or C#, you are usually writing in a high-level language. This means the code is designed to be easier for humans to read and write.

A processor, however, does not understand Python-style instructions such as print("Hello"). The processor can only directly execute machine code: binary instructions specific to that type of CPU.

Definition

High-level language

A high-level language is a programming language that is designed to be understandable by humans and is mostly independent of the hardware it will run on.

Definition

Machine code

Machine code is the low-level binary instruction code that a CPU can directly execute.

Because of this, high-level code needs a translator.

Definition

Translator

A translator is software that converts high-level program code into machine code so that it can be executed by the computer.

Comparison of how compilers and interpreters translate high-level source code into machine code

Key Idea

The big idea

Both compilers and interpreters translate high-level code into machine code, but they do it in different ways and at different times.

What is a compiler?

A compiler translates the whole high-level program into machine code before the program is run.

The original high-level program is often called the source code. The translated machine-code version is often called an executable file or object code, depending on the context.

Definition

Compiler

A compiler is a translator that converts the whole program from high-level code into machine code before execution.

How a compiler works

A simplified GCSE version of compilation is:

  1. The programmer writes the whole source code.
  2. The compiler checks and translates the whole program.
  3. If there are errors, the compiler reports them.
  4. If there are no errors, a machine-code executable can be produced.
  5. The executable can be run without translating the source code again.

So, with a compiler, translation happens before execution.

Main features of compiled programs

Compiled programs are often:

  • faster to run once translated, because the translation has already happened
  • distributable as executable files, so the user may not need the original source code
  • useful when you want to protect the source code from being easily viewed
  • less convenient during development if you need to recompile after changes
Tip

Compiler memory hook

Compiler = complete program first. It translates the whole program before the program runs.

What is an interpreter?

An interpreter translates and runs a program one statement at a time.

Instead of producing a separate executable file first, the interpreter works through the source code during execution.

Definition

Interpreter

An interpreter is a translator that translates high-level code into machine code one statement at a time and executes it immediately.

How an interpreter works

A simplified GCSE version of interpretation is:

  1. The interpreter reads the next statement.
  2. It translates that statement into machine code.
  3. The CPU executes that translated instruction.
  4. The interpreter moves to the next statement.
  5. This repeats while the program is running.

So, with an interpreter, translation happens during execution.

Main features of interpreted programs

Interpreted programs are often:

  • easier to test and debug, because you can run the program and stop when an error is reached
  • slower to run than compiled programs, because translation is happening while the program runs
  • dependent on having the interpreter installed on the machine
  • not usually turned into a separate machine-code executable by the interpreter
Common Mistake

Saying interpreters do not translate

Do not write that an interpreter “does not translate” the program. It does translate high-level code into machine code — it just does it one statement at a time during execution.

Compiler versus interpreter: the key differences

The exam specification asks you to understand how an interpreter differs from a compiler in the way it translates high-level code into machine code.

That means the most important comparison is the method of translation, not just general advantages and disadvantages.

FeatureCompilerInterpreter
Amount translatedTranslates the whole programTranslates one statement at a time
When translation happensBefore the program runsDuring program execution
OutputUsually produces a machine-code executableUsually does not produce a separate executable
Error handling in GCSE termsReports errors after checking/compiling the codeStops when it reaches an error
Running againExecutable can be run again without recompiling, unless the source code changesSource code is translated again each time it is run
Speed while runningUsually faster after compilationUsually slower because translation happens as it runs
Key Idea

Best one-sentence comparison

A compiler translates the whole program into machine code before execution, while an interpreter translates and executes the program one statement at a time during execution.

Worked example: identifying the translator from behaviour

Example

Identifying the translator from behaviour

A program is translated into machine code. The translator reads the first statement, translates it, executes it, then moves to the next statement. When it reaches an error, the program stops at that point. Decide whether this describes a compiler or an interpreter.

  1. The translator is not translating the whole program before running it; it is handling one statement at a time.
  2. Each statement is executed immediately after it has been translated, so translation is happening during execution.
  3. Stopping when it reaches an error matches the GCSE description of an interpreter.
  4. Therefore, the translator is an interpreter.

Why programmers might use a compiler

A programmer might choose a compiler when they want the final program to run efficiently.

For example, a game or large application may be compiled so that users can run the finished executable without translating the whole source code each time.

A compiler is also useful when distributing software because the user normally receives the executable file rather than the original source code.

However, during development, compilation can take time. If you change the source code, you usually need to compile it again before running the updated version.

Why programmers might use an interpreter

A programmer might choose an interpreter when they are developing and testing code.

Because the interpreter works through the program step by step, it can be useful for finding where an error occurs. This is one reason interpreted languages are often beginner-friendly.

Python is commonly described at GCSE as an interpreted language. In real computer systems, translation can be more complicated, but for Edexcel GCSE you should focus on the clear distinction: line-by-line during execution versus whole program before execution.

Common Mistake

Real systems can be more complex

Some modern languages use mixed approaches, such as bytecode or virtual machines. For GCSE 1CP2, keep your answer focused on the expected comparison: compiler translates the whole program before execution; interpreter translates and executes one statement at a time.

Worked example: choosing which translator suits the situation

Example

Choosing a translator for development or distribution

A programmer is creating a new program and keeps testing small changes. Later, they want to send the finished program to users as a file that runs quickly. Which translator is more suitable at each stage?

  1. During development, the programmer needs to test changes often and find errors easily, so translating and running one statement at a time is helpful.
  2. That behaviour matches an interpreter, because it translates during execution and can stop where an error occurs.
  3. For the finished program, the programmer wants users to run it quickly without translating the source code each time.
  4. That behaviour matches a compiler, because it produces machine code before execution, often as an executable file.
  5. So, an interpreter is more suitable during testing, while a compiler is more suitable for distributing the final program.

Common exam wording to recognise

Questions may use different phrases for the same core ideas.

If you see:

  • “translates the whole program” → think compiler
  • “before the program is executed” → think compiler
  • “produces an executable file” → think compiler
  • “translates one line/statement at a time” → think interpreter
  • “translates during execution” → think interpreter
  • “stops when it reaches an error” → think interpreter
Common Mistake

Only giving advantages

If the question asks how an interpreter differs from a compiler, do not only write “one is faster” or “one is easier to debug”. You must explain the translation difference: whole program before execution versus one statement at a time during execution.

A careful note about errors

At GCSE level, you can say:

  • a compiler checks/translates the whole program and then reports errors
  • an interpreter stops when it reaches an error during execution

This is useful in exam answers, but remember the main focus of this spec point is not detailed error types. The key focus is how high-level code is translated into machine code.

Exam technique

In the exam

  1. If asked to compare them, write paired points: “A compiler does X, whereas an interpreter does Y.”
  2. Always include the translation timing: compiler before execution; interpreter during execution.
  3. Mention the amount translated: compiler translates the whole program; interpreter translates one statement at a time.
Self review

Check yourself

  • What does the CPU directly execute: high-level code or machine code?
  • How does a compiler translate a program differently from an interpreter?
  • Why might an interpreter be useful while a programmer is testing code?
You've reached the end

Test yourself on this topic, or move on to the next guide.

FlashcardsSelf-test with active recall
Why computers are networkedUp next

How was this guide?

Interpreters versus compilers Revision Guide

  1. GCSE
  2. /Computer Science
  3. /Interpreters versus compilers