GCSE · Computer Science · OCR · Spec J277

Interpreter

Picture a translator who speaks each sentence the moment it's translated, then waits for the next. Nothing written down. That's an interpreter.

Computer Science · Translators

Watch an interpreter work, one line at a time

A made-up program, four lines. Press Next and watch translating and running take turns.

Before you press Next: which will happen first for line 2, translating it or running it?

1 name = "Ada"
2 OUTPUT "Hello " + name
3 total = 2 + 3
4 OUTPUT total

Variables

name=not set yettotal=not set yet

Output

 

Step 1: The interpreter translates line 1 only. Lines 2, 3 and 4 haven't been looked at.

1 / 9

Press Next and watch: translate a line, then run it, then the next line.

Step 1 of 9: The interpreter translates line 1 only. Lines 2, 3 and 4 haven't been looked at..

Exam line: Translate a line, run it, move on, and when the last line has run, no executable file is left behind.
Watch out: This program is an invented example for the demo. It is not tied to any particular language.

Computer Science · Translators

What do you think happens to the code?

A program has just been run by an interpreter.

Which is closest to what you think right now?
How sure are you?

Computer Science · Translators

Compiler, interpreter, or both?

Put each statement where it belongs. If it's true of both, drop it in the overlap.

  • A Compiler
  • B Interpreter
  1. Translates the whole program at once
  2. Translates the program one line at a time
  3. Creates a single executable file
  4. Is needed every time the code is run
  5. Translates high-level code

Computer Science · Translators

Your turn: explain it in your own words

Describe how an interpreter translates and runs a program, and say how this differs from a compiler. [5 marks]

0 words · your answer stays on this page and is not sent anywhere.

WHAT YOU'VE LEARNED

A quick recap of today's lesson.

The translator that never finishes translating before it starts running.

What you need to know

  • An interpreter is a translator for high-level code.
  • It translates and runs the program one line at a time.
  • So the rhythm is: translate a line, run it, then move on to the next.
  • Have a goA made-up program has 3 lines. An interpreter has just finished running line 1. What does it do next, and has line 3 been touched yet?

    It translates line 2 (then runs it). Line 3 hasn't been touched.

    It handles one line at a time, so line 3 waits until line 2 has been translated and run.

  • An interpreter does not produce an executable file.
  • That means the interpreter is needed every time the code is run.
  • Have a goDev says: "I ran my program through an interpreter yesterday, so today I'll just double-click the file it made." Dev is very confident. Is Dev right?

    No. An interpreter makes no executable file, so there is no file to double-click.

    No executable file is produced, so the interpreter is needed every time the code is run.

  • A compiler is also a translator for high-level code.
  • A compiler translates the whole program at once.
  • Its result is a single executable file.
  • Have a goMaya compiles a 20-line program. Does she end up with 20 files (one per line) or just one?

    Just one: a single executable file.

    A compiler translates the whole program at once, and the result is a single executable file, not one per line.

The big picture

An interpreter is a translator for high-level code that translates and runs a program one line at a time, without producing an executable file, so it is needed every time the code is run. A compiler is different: it translates the whole program at once into a single executable file. Both are translators for high-level code.

Key points

1Interpreter: translates and runs high-level code one line at a time, with no executable file produced.
2Because no executable file is left, the interpreter is needed every time the code is run.
3Compiler: translates the whole program at once into a single executable file.
4Both compilers and interpreters are translators for high-level code.

Worked example

Problem

A made-up 3-line program is run by an interpreter. Line 1: OUTPUT "Go". Line 2: speed = 4. Line 3: OUTPUT speed * 2. (a) While the interpreter is working on line 2, what has happened to line 1 and to line 3? (b) The program ends. What is left behind, and what is needed to run it again tomorrow?

⚠ Watch out

Assuming an interpreter builds an executable file like a compiler does, so the program can be run again without it. It doesn't: nothing is left behind.

🧠

Memory hook

Think of a live interpreter at a conference: translate a sentence, say it, wait for the next, and no written copy left at the end. A compiler is the translator who hands you the whole translated document. (An analogy to remember it by, not the definition.)

✓

Check yourself

Without scrolling back: what does an interpreter do with line 1 before it touches line 2, and what is left behind when the last line has run?

Flashcards

(7)
What is an interpreter?
A translator that translates and runs high-level code one line at a time, without producing an executable file.
What happens to each line when an interpreter runs a program?
It is translated, then run, before the interpreter moves on to the next line.
Does an interpreter produce an executable file?
No. That is why the interpreter is needed every time the code is run.
What is a compiler?
A translator that translates the whole program at once into a single executable file.
What do compilers and interpreters have in common?
Both are translators for high-level code.
Compiler or interpreter: which one translates one line at a time?
The interpreter.
Compiler or interpreter: which one ends with a single executable file?
The compiler.

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 OCR GCSE Computer Science topics

See the full OCR Computer Science curriculum →

How this lesson was checked. This OCR GCSE Computer Science (specification J277)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 9 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.