Translators

Computers only understand machine code — that’s binary (1s and 0s). But humans write code using high-level languages like Python or Java.

A translator is a program that converts high-level code into machine code so the computer can understand and run it.

There are two main types of translators you need to know about:

Compilers

A compiler translates the whole program into machine code before the program runs.

Advantages of a Compiler:

  • Program runs faster once compiled.

  • You don’t need the original code to run the program again.

Disadvantages of a Compiler:

  • You must wait for the entire program to compile before running it.

  • If there are errors, they’re all reported at once, which can be harder to debug.

Interpreters

An interpreter translates and runs the code line by line.

Advantages of an Interpreter:

  • You can test and run code quickly — great for beginners.
  • Errors are shown as you go, making them easier to find and fix.

Disadvantages of an Interpreter

  • Runs slower, because it translates every time.
  • You need the original code to run the program.

Can you tell the difference between a compiler and an interpreter — and when you might use each one?

Understanding how code is translated helps you appreciate how your programs actually run behind the scenes!

National 5 Target

You should be able to describe the role of a translator.

You should be able to explain what a compiler and interpreter do.

You should be able to compare the advantages of compilers and interpreters.