Lost in Translation
How code written by people becomes code a computer can run: low-level against high-level languages, and the three translators that do the job, the assembler, the compiler and the interpreter, and above all when each one does its translating.
Get the method right under pressure
Free interactive practice on the steps that lose marks under exam pressure.
Start revising freeWhat you'll cover
Speaking the computer language
A computer processor can only run machine code, made of binary. People find binary very hard to write, so they use languages that are easier for humans and then have them translated. Low-level languages such as assembly are close to machine code, while high-level languages such as Python are close to human language. A translator turns the code a person writes into machine code the computer can run. There are three translators to know: the assembler, the compiler and the interpreter. This module covers the languages and the translators, and above all when each one does its work.
Translation words
Learn these before you sort any language or translator. The key idea is when the translation happens.
Compiler against interpreter
These two translators are compared most often, and the comparison must be like for like, weighing the same kind of point on each side.
How to tell translators apart
The surest way to sort the translators is to ask when the translation happens and what it starts from. One turns low-level assembly straight into the binary the processor runs. One turns a whole high-level program into that binary in advance, so it can run fast on its own. One works through a high-level program a line at a time while it runs, which makes errors easy to spot but slows things down. When you compare two of them, weigh the same kind of point on each side rather than mixing speed against something unrelated.
Match the translator to its job
- assembler
- compiler
- interpreter
- machine code
- turns assembly language into machine code
- turns a whole program into machine code before it runs
- turns a program into machine code line by line as it runs
- the binary a processor can run directly
What does a compiler do?
How does a compiler translate a program?
- It translates the whole program into machine code before it runs.
- It translates and runs the program one line at a time.
- It turns assembly language into machine code.
- It does not translate the code at all.
Advantages of high-level code
Select the TWO advantages of writing in a high-level language rather than machine code.
- It is easier for people to read and write
- It can run on different types of computer
- It is already written in binary
- It never needs translating to run
Count the translators
There are 3 translators in total: the assembler, the compiler and the interpreter. Just 1 of them, the assembler, works on low-level assembly language. Subtract to find how many of the translators work on high-level languages. What is the answer?
Order how a compiler works
Put the steps of running a program with a compiler in order, earliest first.
- A programmer writes the program in a high-level language
- The compiler translates the whole program at once
- A file of machine code is produced
- The file runs on its own, quickly
Complete the facts
The binary a processor runs directly is _____ code. The translator that turns assembly into it is an _____. The translator that turns a whole program into it before running is a _____. The translator that works line by line as the program runs is an _____.
Match the language or tool to its feature
- machine code
- assembly language
- a high-level language
- an interpreter
- binary that runs on the processor with no translation
- short codes one step above machine code
- close to human language and easy to read
- makes finding errors easier by stopping at them
Spot the true translator facts
Tap the TWO statements that are true about languages and translators.
- A compiler translates the whole program before it runs
- An interpreter works through a program line by line
- High-level code is already machine code
- High-level code never needs translating
Name the translator
Read each case and choose the best answer.
- A tool turns a finished high-level program into one machine-code file in advance, so the program then runs quickly on its own. Which translator is this?
- A tool runs a program one line at a time, stopping at the first line that has an error, which makes bugs easy to find. Which translator is this?
- A student writes that a compiler is better because it is faster and an interpreter is better because it is blue. Why is this comparison weak?
Explain languages and translators
Explain the difference between low-level and high-level languages and compare the three translators, saying when each does its work.
- Explain the difference between a low-level and a high-level language
- Explain what an assembler does
- Explain the difference between a compiler and an interpreter, comparing like for like
- Give one advantage of a compiler and one advantage of an interpreter