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.
Why translate?
Reason it through
Why does high-level code have to be translated at all?
First link · your turn
A computer is handed an instruction in a program. Does it work out what you probably meant?
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 ' + name3 OUTPUT 'Goodbye'
| Route | name | Translating | Executable file |
|---|---|---|---|
| Interpreter | not set yet | line 1 | none |
Output
Step 1: The interpreter picks up line 1 and translates it. Lines 2 and 3 haven't been touched.
Step through the trace — every value is the lesson’s, not run by the page.
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
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"?
What is machine code?
Do all CPUs have the same machine code instructions?
What is a high-level language?
What do compilers and interpreters have in common?
Why are translators necessary?
How does a compiler translate a program?
What can you do with the executable file a compiler creates?
How does an interpreter work?
Does an interpreter create an executable file?
When is an interpreter needed?
What is the main difference between a compiler and an interpreter?
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 postedMore Edexcel GCSE Computer Science topics
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.