Computer Science Essentials, Unit 11, Lesson 2 of 3

Compilers, interpreters and assemblers

GCSE Computer Science, Languages and translators, 20 minutes

Sign in

Why code must be translated, and how compilers, interpreters and assemblers differ.

What you will learn

  • Explain why translation is needed
  • Compare compilers and interpreters
  • Choose a translator for a situation

Why translate?

The CPU only understands machine code, so source code, the program as the programmer wrote it, must be translated.

A compiler's output is object code: machine code saved as an executable file that runs without the translator.

CompilerInterpreter
Howtranslates the whole program oncetranslates and runs one line at a time
Errorsreports them all at the endstops at the first error
Outputan executable fileno file: it runs the source directly
Runningfast; no translator neededslower; the interpreter is needed every time
Source codestays privatemust be shared
Good forfinished softwarewriting, testing and learning

An assembler translates assembly language into machine code, one instruction for one instruction.

A drawback of a compiler is that after any change the whole program must be compiled again before it can be tested. An interpreter can run the changed line straight away, which suits writing and testing, but it is needed every time the program runs.

The rest of this lesson and its 7 practice questions are locked.

In this lesson

  1. Why translate?
  2. Try it: Which translator?

7 practice questions, marked as you go; about 20 minutes in all.

Key terms

Source code, Executable, Assembler

In this unit: Languages and translators

High-level and low-level languages, machine code and assembly language, compilers, interpreters and assemblers, IDEs, and the three kinds of error.

All of Languages and translators