GCSE · Computer Science · AQA · Spec 8525

Compiler

You type score = score + 1. Your processor can't run that. It only runs machine code: 1s and 0s. So who does the translating, and when?

Sort the translators

Compiler, interpreter or assembler?

Nine claims, three translators. For each claim, tick every translator it's true of: one, two, all three, or none. Have a go before you check. A wrong guess here teaches you more than a lucky one.

  • A Compiler
  • B Interpreter
  • C Assembler
  1. Is a translator
  2. Translates a high-level language
  3. Translates the whole high-level program at once
  4. Translates and runs high-level code line by line
  5. Turns a high-level program into a single executable file
  6. Is needed every time the high-level code is run
  7. Translates assembly language, written in mnemonics such as ADD, into machine code
  8. Turns each assembly instruction into exactly one machine code instruction
  9. Works out what you meant and quietly fixes a wrong instruction

Predict, then check

Mia's program translated with no problems. Now it runs.

Mia wants her game to add 10 bonus points. She types: score = score - 10. The score is 50. What happens when this line runs?

Language levels

From readable to runnable

Tick every property each kind of language has, then check. Read down each column: that's where the pattern is.

High-level language
Assembly language
Machine code

Name that level

Which kind of language is this line?

Pick a line, then pick its level. These lines are made-up illustrations, not code for any real processor.

Still to sort

High-level language (0)

Statements a person can read through

Assembly language (0)

Short mnemonics standing in for machine code

Where the line is: More readable than binary, but a mnemonic like ADD is not a high-level statement: assembly is still low-level.

Machine code (0)

Binary: nothing but 1s and 0s

4 of 4 still to sort.

Your turn to write

Why translate, and how?

A programmer writes a game in a high-level language. Explain why the game must be translated before the CPU can run it, and give one difference between translating it with a compiler and with an interpreter. [3 marks]

0 words · your answer stays on this page and is not sent anywhere.

WHAT YOU'VE LEARNED

A quick recap of today's lesson.

Your CPU only runs machine code. Meet the three translators that get your code there, and learn to tell the compiler, the interpreter and the assembler apart for good.

What you need to know

  • A CPU can only run machine code directly: binary 1s and 0s, and different CPUs have different instructions.
  • Have a goA machine code program runs perfectly on Leo's laptop. He copies it onto a computer with a different CPU and says: 'Bound to work, it's all just 1s and 0s.' Safe bet?

    No, not a safe bet.

    1s and 0s aren't universal: different CPUs have different machine code instructions, so instructions one CPU understands may not mean the same thing to another.

  • Computers run instructions exactly as written, with no guessing, so instructions must be precise.
  • High-level languages are easier for humans to read and hide the hardware details; one line can become many machine code lines.
  • Low-level languages are close to machine code: direct hardware control, harder to read, and programs that tend to run quickly.
  • Assembly language is low-level, swapping binary for short, readable mnemonics such as ADD.
  • Translators exist so you don't have to write everything in machine code.
  • An assembler translates assembly language into machine code, one machine code instruction per assembly instruction.
  • Have a goAn assembly program is 20 instructions long. How many machine code instructions does the assembler produce?

    20.

    Each assembly instruction becomes exactly one machine code instruction. 'Many' is something that can happen with high-level code, not assembly.

  • A compiler translates a whole high-level program into machine code at once, creating an executable file.
  • That executable file can be run without the original code.
  • An interpreter translates and runs code line by line, creates no executable, and is needed every time the code runs.
  • Have a goYou run a high-level program through an interpreter today. Tomorrow you want to run it again. Will you need the interpreter?

    Yes, every time.

    An interpreter makes no executable file to keep, so the code has to be translated and run line by line again.

The big picture

A CPU only runs machine code directly, and it runs every instruction exactly as written. High-level languages are readable and hide the hardware; low-level languages, including assembly with mnemonics such as ADD, are close to machine code. An assembler translates assembly into machine code, one instruction to one. A compiler translates a whole high-level program at once into an executable that runs without the original code; an interpreter translates and runs it line by line and is needed every time.

Key points

1A CPU only runs machine code directly, so high-level and assembly code must be translated first.
2Compiler: the whole program at once, creating an executable that runs without the original code.
3Interpreter: translates and runs line by line, makes no executable, and is needed every time.
4Assembler: assembly language into machine code, one instruction to one.
5Computers run instructions exactly as written, so precise instructions matter.

Worked example

Problem

A student writes: 'A compiler and an interpreter both turn high-level code into an executable file. The interpreter just does it line by line.' What's right, what's wrong, and how would you fix it?

⚠ Watch out

Saying an interpreter creates an executable file, or that a compiler works line by line. It's the compiler that translates the whole program at once and creates an executable that runs without the original code. The interpreter translates and runs line by line and is needed every time the code runs.

🧠

Memory hook

Compiler = Complete: the whole program once, and you keep the executable. Interpreter = In the moment: line by line, every single run. Assembler = Assembly, one for one.

✓

Check yourself

Cover the page. Write one sentence each for the compiler, the interpreter and the assembler, saying what it translates and how. Then underline the one job two of them share.

Flashcards

(14)
What does a compiler do?
Translates a high-level language into machine code all at once, creating an executable file.
How does an interpreter work through code?
It translates and runs the code line by line.
What can a compiler's executable file run without?
The original code.
What is machine code?
The lowest-level language: binary instructions (1s and 0s) that the CPU can run directly.
Is there one machine code that every CPU shares?
No. Different CPUs have different machine code instructions.
Give two features of high-level languages.
They're more human-readable than low-level languages, and they hide the complex details of the hardware.
How much machine code can one line of high-level code become?
Many lines of machine code.
Why might a programmer pick a low-level language?
Direct control over the hardware, and programs that tend to run quickly; it's efficient for system programming.
What's the downside of low-level languages?
They tend to be hard to read, and the programmer has to manage memory and hardware details.
What is assembly language?
A low-level language that replaces machine code with short, readable mnemonics such as ADD.
What does an assembler do?
Translates assembly language into machine code: each assembly instruction becomes one machine code instruction.
Why do we need translators at all?
Without them, the only option would be to write programs in machine code.
What does a computer do with an instruction that's wrong?
Runs it exactly as written, without guessing what you meant. So instructions must be precise.
Which two translators can translate a high-level language?
A compiler or an interpreter.

Tap any card to flip it, or use Study as deck to go through them one at a time. In the full lesson these run as a spaced-repetition deck — you rate each card Hard, Good or Easy and the tricky ones keep coming back until they stick.

Learning with Lightbulb is opening soon

You can use this lesson now. Join the waitlist and we'll let you know when the full Lightbulb experience is ready.

Keep me posted

More AQA GCSE Computer Science topics

See the full AQA Computer Science curriculum →

How this lesson was checked. This AQA GCSE Computer Science (specification 8525)lesson was published through Lightbulb Learning's human-designed editorial process — the educational standards, accuracy rules and publication checks it must pass were authored and approved by Philip Halpin. It passed subject-specific assessment, automated educational checks and technical publication verification before going live (publication checks completed 4 November 2026). Published pages are monitored, human spot-checking is ongoing across the lesson library, and anything found wrong is corrected or withdrawn. How our lessons are made and checked. Spotted a mistake? Email hello@lightbulblearning.co and we'll review it.