In simple terms
A friendly intro before the formal notes — no formulas yet.
Code Translators: From Our Language to Theirs
Computers only understand binary, a language of 1s and 0s. Translation software acts like a multilingual expert, converting the high-level languages we write in (like Python or Java) into the machine code the CPU can execute.
Imagine you've written a novel in English and need it read by people in France. A compiler is like a translator who takes your entire book, translates it into French, and gives you a complete French version to print and distribute. An interpreter is like a live translator at a UN meeting; they listen to one sentence in English, translate it into French aloud, then wait for the next sentence. An assembler is a highly specialised translator for a technical manual written in a very specific shorthand (assembly language), turning it into the final machine instructions.
- 1
A programmer writes source code in a high-level language like Python or Visual Basic.
- 2
The source code is fed into a translator program: either a compiler or an interpreter.
- 3
A compiler processes the entire file, creating a separate executable file of machine code. An interpreter reads and executes the code one line at a time.
- 4
The CPU runs the resulting machine code, either from the executable file or as directed by the interpreter, to perform the program's tasks.
Explore the concept
Use the live diagram and synced steps — play it or tap a step card to walk through.
Full topic notes
Formal explanation with the rigour you need for the exam.
The Three Main Types of Translators
There are three categories of translation software you need to know. While they all convert code from one form to another, their methods and outputs are distinct, making them suitable for different tasks.
- Compiler: Translates a whole program at once into a standalone executable file.
- Interpreter: Translates and executes a program one line at a time.
- Assembler: A special-purpose translator for converting low-level assembly language into machine code.
In-depth: The Compiler and its Stages
A compiler takes your entire source code file (e.g., ) and runs it through a multi-stage process to produce an executable file (e.g., ). This executable can be run directly by the operating system without the compiler or source code present. This process makes for very fast execution but can make debugging slower, as any change requires a full recompilation.
Lexical Analysis: The source code is read, and whitespace/comments are removed. The code is broken down into a stream of 'tokens'. For example, becomes IDENTIFIER(x), , , SEMICOLON.
Syntax Analysis (Parsing): The stream of tokens is checked against the grammar rules of the language. The compiler builds a data structure, like a parse tree, to represent the program's structure. If the code breaks a rule (e.g., ), a syntax error is reported.
Semantic Analysis: The meaning of the code is checked. This stage catches errors that are grammatically correct but logically nonsensical, such as trying to add a string to an integer in a strongly-typed language, or using an undeclared variable.
Intermediate Code Generation & Optimisation: The compiler generates a low-level, platform-independent version of the code. It then optimises this code to make it faster or smaller, for example, by removing redundant calculations.
Code Generation: The optimised intermediate code is translated into the final machine code for the target CPU architecture.
Linking: The generated object code is combined with code from libraries (e.g., for printing to the screen) to produce the final executable file.
The Interpreter
An interpreter works differently. Instead of producing a separate executable, it reads the source code one line at a time, translates that line into machine code, and executes it immediately. It then moves to the next line. This makes the development and debugging cycle very fast, as you can run your code instantly after a change and errors are reported as they happen. However, this line-by-line translation at runtime means interpreted programs generally run much slower than compiled ones.
A classic exam question involves comparing compilers and interpreters. Be prepared to discuss their differences in terms of: speed of execution (compiler wins), speed of translation/development (interpreter wins), portability (interpreted code is more portable), error reporting (interpreter reports errors at runtime, line-by-line; compiler reports all syntax errors at once before execution), and distribution (compiler produces a standalone executable).
The Assembler
The assembler is the simplest type of translator. It converts assembly language, a low-level language that uses mnemonics (like MOV, ADD, JMP), into the binary machine code that the CPU understands. Each assembly instruction typically corresponds directly to one machine code instruction. This provides direct control over the hardware and is used for tasks where performance is absolutely critical, such as in device drivers or the boot-up code for an operating system.
Worked examples
See the formulas applied — reveal one step at a time, like the exam.
For the following line of Pascal code, , describe the output of the Lexical Analysis stage and draw a simplified representation of the parse tree created during Syntax Analysis.
- 1
Mark Scheme Breakdown:
A software company is developing a new video game for high-performance PCs. The game requires maximum graphical performance and fast processing to handle complex physics. The company also wants to protect its source code from being copied. Justify whether a compiler or an interpreter would be the more appropriate choice for distributing the final game.
- 1
Mark Scheme Breakdown:
How it all connects
The big idea sits in the middle — tap a linked idea to explore the link.
Tap a linked idea to see how it connects back to the main topic — that connection is what examiners reward.
Glossary
Try to recall each definition before you reveal it.
Quick check
Answer in your head first — then tap to check. No pressure.
Revision flashcards
Flip the card. Test yourself before the exam.
What is a compiler?
A program that translates an entire high-level language source file into a standalone executable file (object code or machine code) in one go, before the program is run.
Key takeaways
Review these before you close the topic — retrieval beats re-reading.
- ✓
Lexical Analysis: The source code is read, and whitespace/comments are removed. The code is broken down into a stream of 'tokens'. For example, becomes IDENTIFIER(x), , , SEMICOLON.
- ✓
Syntax Analysis (Parsing): The stream of tokens is checked against the grammar rules of the language. The compiler builds a data structure, like a parse tree, to represent the program's structure. If the code breaks a rule (e.g., ), a syntax error is reported.
- ✓
Semantic Analysis: The meaning of the code is checked. This stage catches errors that are grammatically correct but logically nonsensical, such as trying to add a string to an integer in a strongly-typed language, or using an undeclared variable.
- ✓
Intermediate Code Generation & Optimisation: The compiler generates a low-level, platform-independent version of the code. It then optimises this code to make it faster or smaller, for example, by removing redundant calculations.
- ✓
Code Generation: The optimised intermediate code is translated into the final machine code for the target CPU architecture.
- ✓
Linking: The generated object code is combined with code from libraries (e.g., for printing to the screen) to produce the final executable file.
Practice — then mark it
The whole point: a real Cambridge question, marked mark-by-mark.
Test Your Knowledge on Translation Software
Test Your Knowledge on Translation Software
Extra simulations & links
PhET, GeoGebra and other curated tools — open in a new tab.
Frequently asked
Checkpoint
One marked question is worth ten re-reads — close the loop before you move on.
Reading it isn’t knowing it — prove it.
Before you move on: do Test Your Knowledge on Translation Software on paper, snap a photo, and get examiner-style feedback on exactly where you win and lose marks.