DoRevision

Lost in Translation

Compilers and interpreters both turn code a person wrote into something a processor can run. The whole difference is when they do it, and almost every advantage of each follows from that.

⏱️ 20 min 🎯 12 activities
Best used for
Independent study Mock preparation Cover lesson

Get the method right under pressure

Free interactive practice on the steps that lose marks under exam pressure.

Start revising free

What you'll cover

When the translation happens

A compiler and an interpreter do the same job. Both take code that a person wrote and turn it into something a processor can actually run. Every textbook then gives you a table of differences to learn, and the table looks like six unrelated facts. It is not. There is exactly one difference between them, and everything else in the table follows from it. A compiler does the translation before the program runs. It takes the whole thing, translates it all at once, and hands you a finished file that can be run on its own afterwards. An interpreter does the translation while the program runs, taking one line at a time and translating it at the moment it is needed, which means it has to be there every time the program is used. That is the whole distinction: when. Keep asking what follows from when, and you can rebuild the comparison table instead of memorising it, which is a great deal more reliable under exam pressure.

Words for the two kinds

Five terms your specification uses. The first two describe kinds of language; the rest describe what happens to them.

Closer to the machine

Why might a programmer choose a low-level language rather than a high-level one, given that high-level code is easier to write?

  • Because it gives direct control over what the hardware does, which matters where memory or speed is tightly constrained
  • Because low-level code is quicker to write
  • Because low-level code runs on any processor
  • Because low-level code needs no translation at all

Match each language to what it is

  • Written to be readable by people, with one instruction standing for many machine operations
  • Close to what the processor works with, giving direct control over the hardware
  • The binary instructions a processor actually executes
  • Code as the programmer wrote it, before any translation has happened
  • A high-level language
  • A low-level language
  • Machine code
  • Source code

Before it runs, or while it runs

Read this as cause and effect rather than as two lists. The first row is the only real difference; every row below it follows from that one.

Which two follow from compiling

Select the TWO statements that follow from a compiler translating the whole program before it runs.

  • The finished program runs faster, because no translating happens while it is running
  • The program can be given to someone who does not have the translator
  • The program stops at the first error so faults are easy to find
  • The translator must be installed on every machine that runs the program

What your specification leaves out

One thing is worth knowing before you revise from a textbook or a website, because it will save you time. You may meet a third translator called an assembler, which converts assembly language into machine code. It is a real thing and it is genuinely part of this subject. It is also not required by your specification: OCR asks you to understand compilers and interpreters, and states plainly that an understanding of assemblers is not required. Some other exam boards do require it, which is why so much revision material includes it, and if a friend on another course tells you there are three translators to learn, they are not wrong about their own course. For yours there are two, and your time is better spent being able to explain the compiler and interpreter comparison properly than adding a third item you will not be asked about. That said, it is worth knowing the word exists, so that meeting it does not throw you in a reading question. Knowing what is outside your specification is part of revising well, and it is the sort of thing only somebody looking at your particular syllabus can tell you.

The trade in words

A compiler translates the _____ program before it runs, which is why it produces a file that can be run on its _____ and why that file executes _____. An interpreter translates one _____ at a time as the program runs, which is why the translator must be present every time and why it is easier to find faults: it stops at the _____ error it meets rather than reporting them together.

whole own faster line first partial slower word last machine

The comparison that does not match

Four sentences comparing compilers and interpreters. Select the ONE that compares two different things and so proves nothing.

  • Compiled programs execute faster than interpreted ones, because translation happens beforehand.
  • Interpreters make debugging easier than compilers do, because they stop at the first error.
  • Compilers are better because compiled code runs quickly, whereas interpreters are written in high-level languages.
  • A compiled program can be distributed without the translator, whereas an interpreted one cannot.

Say why the difference matters

Assemble a sentence that explains a difference rather than just stating it.

Choosing a translator

You are advising on which kind of translator suits each situation. Take the decisions in order.

  • A program is being written and tested, with small changes made constantly. Which suits that better?
  • The finished program is to be given to users who will not have any development tools. Which suits that?
  • Someone asks why compiled code runs faster. What is the accurate reason?
  • A revision website tells you to learn three translators. What should you do?

Explain the two translators

A friend has learned the compiler and interpreter comparison as a list of facts and keeps mixing it up. Explain the two translators so that the differences make sense rather than needing to be memorised.

  • Explain the difference between a high-level and a low-level language, and give one advantage of each
  • Explain what machine code is and why it is specific to a kind of processor
  • State the one real difference between a compiler and an interpreter
  • Explain why compiled code runs faster, as a consequence of that difference
  • Explain why an interpreted program is easier to debug, as a consequence of the same difference
  • Explain why a compiled program can be distributed without the translator
  • Compare the two like for like, rather than setting a strength of one against an unrelated point about the other
  • Finish by saying which you would choose while developing a program, and which for releasing it