GCSE · Computer Science · Edexcel · Spec 1CP2

Interpreters vs compilers

Send a friend your program: do they get one file they can just run, or code that needs something extra? It all depends on how it's translated.

Sort it out

Compiler, interpreter, or both?

Tick Compiler, Interpreter, or both for each feature, then check. Hint: some features belong in the overlap.

  • A Compiler
  • B Interpreter
  1. Translates a high-level language into machine code
  2. Lets programmers write in structured, human-readable language
  3. Translates the whole program at once
  4. Creates an executable file
  5. Result can be run without the original code or the translator
  6. Translated version can be shared with others
  7. Translates and executes one line at a time as the program runs
  8. Creates no executable file
  9. Needed every time the program is run

Why translate?

?

Reason it through

Why does high-level code have to be translated at all?

Link 1 of 4

First link · your turn

A computer is handed an instruction in a program. Does it work out what you probably meant?

2
Locked — reveal the link above first
3
Locked — reveal the link above first
4
Locked — reveal the link above first

Same program, two routes

When does the translating happen?

Steps 1 to 6 follow an interpreter. Steps 7 to 11 follow a compiler. Watch what is being translated, and whether an executable file appears.

Step through both routes. When does the translating happen in each, and which one leaves an executable file?

1 name ← 'Sam'
2 OUTPUT 'Hello ' + name
3 OUTPUT 'Goodbye'
RoutenameTranslatingExecutable file
Interpreternot set yetline 1none

Output

 

Step 1: The interpreter picks up line 1 and translates it. Lines 2 and 3 haven't been touched.

1 / 11

Step through the trace — every value is the lesson’s, not run by the page.

Step 1 of 11: The interpreter picks up line 1 and translates it. Lines 2 and 3 haven't been touched..

Predict, then check

Sam sends one friend a compiled executable file and another friend the interpreted code.

Who needs a translator on their computer to run Sam's program?

Key terms

Flip each card and say the definition out loud first.

WHAT YOU'VE LEARNED

A quick recap of today's lesson.

What you need to know

  • Computers do not guess what an instruction means. They carry out a program's instructions exactly as written.
  • Machine code is the lowest-level language a computer can run directly, and different CPUs have different machine code instructions.
  • High-level languages are human-readable, written in formal, structured English, so they must be translated before a computer can run them.
  • Have a goPriya says: "I'll just hand my high-level program straight to the computer. It'll cope." What do you tell her has to happen first?

    It has to be translated into machine code first.

    A computer only runs machine code directly. A high-level language is structured English, and the computer carries out instructions exactly as written, so it can't run it as it stands.

  • Compilers and interpreters are both translators: each turns a high-level language into machine code.
  • High-level languages only exist because of translators. Without them, the only option would be to write in machine code.
  • A compiler translates the whole program at once and creates an executable file.
  • Have a goMo's 500-line program has just gone through a compiler. What new thing is now sitting on his computer?

    An executable file.

    A compiler translates the whole program at once and creates an executable file. It doesn't work through the lines one by one while the program runs.

  • An executable file can be run without the original code, used whenever needed and shared with others.
  • An interpreter translates and executes code line by line, one line at a time as the program runs, and creates no executable file.
  • Have a goAn interpreter is working on line 4 of a 10-line program. Which lines has it translated and run, and which not yet?

    Lines 1 to 3 are done. Lines 5 to 10 haven't been reached.

    It translates and executes one line at a time as the program runs. It doesn't translate the whole program in advance.

  • An interpreter is needed every time the code is run, so anyone wanting to run the program needs one.
  • Main difference: a compiler translates all at once, whereas an interpreter translates line by line.

The big picture

Computers can only run machine code, so the high-level code programmers write has to be translated. Compilers and interpreters are both translators. A compiler translates the whole program at once into an executable file. An interpreter translates and executes it line by line as the program runs, so it is needed every time.

Key points

1Computers carry out instructions exactly as written, so high-level code must be translated into machine code first.
2A compiler translates the whole program at once and creates an executable file that can be run without the original code or the translator, and shared.
3An interpreter translates and executes line by line as the program runs, creates no executable file, and is needed every time the code is run.

Worked example

Problem

A programmer says: "My program is translated one line at a time while it runs, and no executable file is made." Which translator is being used?

⚠ Watch out

Thinking a compiler and an interpreter do different jobs. They both translate high-level code into machine code. The difference is how: all at once into an executable file, or line by line as the program runs.

🧠

Memory hook

Compiler: translate it all, then hand over the file. Interpreter: translate line by line, and it has to be there every time the program runs.

✓

Check yourself

Without looking back: name one thing a compiler and an interpreter have in common, and one way they differ.

Flashcards

(12)
What does it mean that a computer executes instructions "exactly as written"?
It carries out each instruction with no interpretation. It doesn't guess what you meant.
What is machine code?
The lowest-level programming language, which a computer can run directly.
Do all CPUs have the same machine code instructions?
No. Different CPUs have different machine code instructions.
What is a high-level language?
A human-readable language written in formal, structured English. It must be translated before a computer can execute it.
What do compilers and interpreters have in common?
Both are translators that turn a high-level language into machine code.
Why are translators necessary?
They let programmers write in structured, human-readable language. Without them, the only option would be to write in machine code.
How does a compiler translate a program?
It translates the whole program at once and creates an executable file.
What can you do with the executable file a compiler creates?
Run it without the original code, use it whenever needed, and share it with others.
How does an interpreter work?
It translates and executes code line by line, one line at a time as the program runs.
Does an interpreter create an executable file?
No.
When is an interpreter needed?
Every time the code is run, so anyone wanting to run the program needs an interpreter.
What is the main difference between a compiler and an interpreter?
A compiler translates the code into machine code all at once. An interpreter translates it line by line.

Tap any card to flip it, or use Study as deck to go through them one at a time. In the full lesson these run as a spaced-repetition deck — you rate each card Hard, Good or Easy and the tricky ones keep coming back until they stick.

Learning with Lightbulb is opening soon

You can use this lesson now. Join the waitlist and we'll let you know when the full Lightbulb experience is ready.

Keep me posted

More Edexcel GCSE Computer Science topics

See the full Edexcel Computer Science curriculum →

How this lesson was checked. This Edexcel GCSE Computer Science (specification 1CP2)lesson was published through Lightbulb Learning's human-designed editorial process — the educational standards, accuracy rules and publication checks it must pass were authored and approved by Philip Halpin. It passed subject-specific assessment, automated educational checks and technical publication verification before going live (publication checks completed 11 November 2026). Published pages are monitored, human spot-checking is ongoing across the lesson library, and anything found wrong is corrected or withdrawn. How our lessons are made and checked. Spotted a mistake? Email hello@lightbulblearning.co and we'll review it.