📁 Paper 2 · 3.4 Computer Systems
3.4.5a Translators — Compilers & Interpreters
AQA 8525 · GCSE Computer Science · ~10 min read
Notes
──
Video
──
Worksheet
──
Quiz

High-Level vs Low-Level Languages

All programs written by programmers must be translated into machine code (binary 1s and 0s) before the CPU can execute them. The tool that does this translation is called a translator.

High-Level Language (HLL)

Written to be easy for humans to read and write. Uses English-like keywords and abstracts away hardware details.

Examples: Python, Java, C#, Visual Basic

One line of HLL code may produce many lines of machine code.

Must be compiled or interpreted before the CPU can run it.

Low-Level Language (LLL)

Closer to machine code. Operates directly on the hardware. Hard for humans to write.

Examples: Assembly language, Machine code

Assembly uses mnemonics (MOV, ADD, JMP) — one instruction = one machine code instruction.

Must be assembled using an assembler.

Compilers

A compiler translates the entire source program into machine code (an executable file) all at once, before the program runs. The resulting executable can be run directly without needing the compiler again.

Source code
(.py, .java…)
Compiler
Object/Executable
(.exe, .class…)
CPU runs it
directly

⚙ Compiler: Advantages & Disadvantages

Resulting executable runs quickly — machine code is pre-generated
Source code is hidden in the executable — protects intellectual property
Executable runs without the compiler present
Errors reported after full compilation — all in one error report
Compilation takes time before the program can run
Hard to debug — errors listed by line number but you cannot step through
Compiled for a specific OS/hardware — not automatically portable
Full recompilation needed after every change to source code

Interpreters

An interpreter translates and executes the source code line by line at runtime. No executable file is created. The interpreter must be present every time the program runs.

Source code
(.py, .js…)
Interpreter
line by line
CPU executes
each line

⚡ Interpreter: Advantages & Disadvantages

Easier to debug — stops at the exact line where an error occurs
Faster development cycle — change code and run immediately, no compilation step
More portable — interpreter on any platform can run the same source code
Runs slower than compiled code — translation happens at runtime every time
Source code must be present (and visible) when distributing
Interpreter must be installed on every machine that runs the program
Stops at first error — later errors not detected until earlier ones fixed

Comparison Table

FeatureCompilerInterpreter
Translation methodWhole program at onceLine by line at runtime
OutputExecutable file (.exe)No output file produced
Execution speedFastSlower
DebuggingHarder (line numbers only)Easier (stops at error line)
Error reportingAll errors after full compilationStops at first error
Source code needed at runtime?No (executable is standalone)Yes
Translator needed at runtime?NoYes (interpreter must be installed)
PortabilityLess portable (OS/hardware specific)More portable (reuse same source)
ExamplesC, C++, Java (javac)Python, JavaScript (browser), Ruby
Exam tip: A common 4-mark question asks to compare a compiler and an interpreter. The key differences are: (1) whole vs line-by-line translation, (2) produces an executable vs no file, (3) fast execution vs slower, (4) harder vs easier debugging. Learn these four pairs.
⚠️ Common Mistakes
  • Saying "an interpreter is faster" — it is NOT. Compiled code runs faster. Interpreter is faster to develop with (no compilation step) but slower to run.
  • Saying an interpreter "converts to machine code permanently" — it does not. Translation happens each time the program runs.
  • Python is typically interpreted. Java is compiled to bytecode then interpreted by the JVM — but for GCSE just say Java uses a compiler (javac).
Video coming soon

Key points

  • High-level language: human-readable, needs compiler or interpreter; Low-level: machine-readable, needs assembler
  • Compiler: translates ALL at once → executable; fast execution, harder debugging, no translator at runtime
  • Interpreter: translates LINE BY LINE at runtime; easier debugging, slower execution, needs interpreter to run
  • Key comparison: speed (compiler faster), debugging (interpreter easier), output file (compiler yes, interpreter no)
Click slide or press arrow keys to navigate
✍️

Worksheet — 3.4.5a Translators

8 questions · 19 marks

Q1What is a translator in computer science? Give one example of a translator.[2]
✅ Mark scheme
Mark scheme
A translator converts source code (high-level or assembly language) into machine code that the CPU can execute [1]; example: compiler, interpreter, or assembler [1].
Q2Describe how a compiler translates a program.[2]
✅ Mark scheme
Mark scheme
A compiler translates the entire source program at once (before it runs) [1]; it produces an executable/object file that can be run directly without needing the compiler again [1].
Q3Describe how an interpreter translates a program.[2]
✅ Mark scheme
Mark scheme
An interpreter translates and executes source code line by line at runtime [1]; no executable file is produced — the interpreter must be present every time the program is run [1].
Q4Give two advantages of using a compiler over an interpreter.[2]
✅ Mark scheme
Mark scheme
Any two: compiled code executes faster [1]; creates a standalone executable — no compiler needed at runtime [1]; source code is hidden in the executable, protecting intellectual property [1].
Q5Give two advantages of using an interpreter over a compiler.[2]
✅ Mark scheme
Mark scheme
Any two: easier to debug — execution stops at the exact error line [1]; faster development cycle — no compilation step, run code immediately after changes [1]; more portable — same source code can run on any platform with an interpreter [1].
Q6Explain why an interpreted program runs more slowly than the same program that has been compiled.[2]
✅ Mark scheme
Mark scheme
The interpreter must translate each line of source code into machine code at runtime every time the program runs [1]; the compiled program is already fully translated — the CPU executes machine code directly without any translation overhead [1].
Q7A developer is writing a game in C++. They find a bug on line 47. Explain whether a compiler or interpreter would make this bug easier to find.[3]
✅ Mark scheme
Mark scheme
An interpreter would make the bug easier to find [1]; the interpreter stops execution at the exact line where the error occurs [1]; a compiler reports all errors after compiling the whole program, giving line numbers only — harder to locate and fix in the context of running code [1].
Q8A software company sells an application. Discuss whether they should distribute it as compiled or interpreted code. Explain your reasoning.[4]
✅ Mark scheme
Mark scheme
Compiled is preferable for distribution [1]; compiled produces an executable — users do not need to install a compiler or interpreter [1]; compiled code runs faster, providing a better user experience [1]; source code is hidden in the executable, protecting the company's intellectual property [1].
Check your answers above.
Topic Quiz
Q 1 of 10
You scored
out of 10
Card 1 of 6
Click to flip
🎉
All done!
TermDefinition
🎯

Mini Test — 3.4.5a Translators

Timed exam conditions.

  • 8 questions · 10 minutes
  • 5 MCQ + 3 short answer
← 3.4.4b OS User Interfaces
40 of 57 · AQA 8525
3.4.5b Assemblers & Bytecode →