Free revision guides

Compiler or interpreter? Spotting the clues

National 5 Computing Science: Computer systems

A processor can only run machine code, so a program written in a high-level language such as Python has to be translated first. National 5 asks about two kinds of translator, usually for 1 mark: name the right one for a situation.

The difference

InterpreterCompiler
How it translatesOne line at a time: translate a line, run it, then the nextThe whole program, before it runs
Every time the program runs?Yes: translated again every timeNo: the machine code it makes runs without being translated again
A loop that repeats 10 timesThe lines in the loop are translated 10 timesThe lines in the loop are translated once
Good forWriting and testing a program: errors show up as each line is reachedA finished program given to other people

The clues in the question

  • "Runs without further translation", "faster to run", "released to the public", "the users don't need the translator": compiler.
  • "Translated each time it runs", "line by line", "while the program is being developed": interpreter.
From the examiners' reports

In 2024 only some candidates named the right translator. One rule settles it: if the program is translated while it runs, every time it runs, it is an interpreter. If it runs without needing to be translated again, it was compiled.

Try two exam-style questions

Choose an answer, say how sure you are, then press Check. Every wrong answer tells you why it is wrong.

The Interpreter or compiler? simulation
In the course: Interpreter or compiler?. Race a compiler against an interpreter on the same program, and see what each does with a loop and with an error.

The full course covers every topic like this. Every topic in National 5 Computing Science has a short note, a simulation to try and a practice quiz with feedback on every answer, plus coding lessons, a full mock exam and a progress report for parents.

Create an accountTry more for freeAbout the course

More guides

This site is independent: it is not connected to the SQA or Qualifications Scotland. Points from the examiners' course reports are given in our own words.