Compilers and interpreters Cambridge IGCSE Computer Science revision
Not started
Learn it
In plain words
A program written in a high-level language has to be translated into machine code before a processor can run it. There are two ways to do the job.
A compiler is like a translator who takes a whole book away and hands back the finished translation. An interpreter is like someone translating a speech as it is given, one sentence at a time.
7 things to know
- A compiler translates the whole of the code at once, before any of it is run. It produces an executable file.
- A compiler gives a report of all the errors in the whole code, if it finds any. No executable file is made until they are corrected.
- An interpreter translates and executes the code one line at a time. No executable file is produced.
- An interpreter stops when it finds an error, at that line. That makes errors easy to find and fix.
- A compiled program runs without the compiler and runs fast, and the source code does not need to be given to the user. But it must be compiled again after every change.
- An interpreted program needs the interpreter every time it runs, and it runs more slowly.
- So an interpreter is mostly used when developing a program, and a compiler is used to translate the final program.
Worked example
A student is writing and testing a new program. Later the finished program will be sold. Which translator suits each stage?
- While writing and testing: an interpreter. It stops at the line with the error, so each mistake can be fixed straight away without translating the whole program again.
- For selling: a compiler. It produces an executable file that runs fast, needs no translator on the buyer's computer, and keeps the source code private.
Tips and tricks
- Do not say an interpreter "translates line by line" and stop. Say it translates and executes each line, and stops when it meets an error.
- "Produces an executable file" is the key fact about a compiler. An interpreter never does.
It lands in your notebook with its questions as flashcards.
Compilers and interpreters: 5 questions and answers
These are the quiz’s questions. Do the quiz first, then come back here for the ones that got you.
What does a compiler do?
The executable file can then be run without the compiler.
How does an interpreter report errors?
Execution stops at the line with the error.
Which is an advantage of a compiled program?
The executable file is all the user needs.
When is an interpreter mostly used?
It makes finding and fixing errors easier.
Why does an interpreted program usually run more slowly?
A compiled program has already been translated.
Quiz
5 questions
Tap an answer and you’ll see straight away whether it’s right, and why.
Worksheet
2 questions, 6 marks. Write your answers on paper, then check them.
Compilers and interpreters
Cambridge IGCSE Computer Science 0478 · 6 marks · papermunch.org
Name ______________________________ Date ______________
Describe two differences between a compiler and an interpreter.[4]
Show answerHide answer
A compiler translates the whole program at once, but an interpreter translates and runs it one line at a time. A compiler reports all the errors together at the end, but an interpreter stops at the first error it finds. (Also: a compiler produces an executable file and an interpreter does not.)
Explain why an interpreter is useful while a program is being developed.[2]
Show answerHide answer
It stops at the line where an error is found, so the error is easy to locate and correct. The program can be tested again without translating all of it.
Answers: Compilers and interpreters
- 1. A compiler translates the whole program at once, but an interpreter translates and runs it one line at a time. A compiler reports all the errors together at the end, but an interpreter stops at the first error it finds. (Also: a compiler produces an executable file and an interpreter does not.)
- 2. It stops at the line where an error is found, so the error is easy to locate and correct. The program can be tested again without translating all of it.



