Software · 4 question types
Past paper frequency (2018 to 2024)
This topic accounts for approximately 4% of your exam marks.
Compiler vs interpreter differences are a recurring 3-mark question.
Every programming language sitting above raw machine code must first be converted into machine code before the CPU can execute it. A translator is the piece of software that performs this conversion. Three kinds appear in the syllabus:
| Translator | Translates | Used for |
|---|---|---|
| Assembler | Assembly language → machine code | Low-level (2nd generation) source code |
| Compiler | High-level language → machine code, all in one go | Programs that are finished and ready to distribute |
| Interpreter | High-level language → machine code, line by line, running each line straight after translation | Programs that are being developed or run interactively |
The simplest of the three. An assembler takes an assembly-language source file and produces an equivalent machine-code file. Because the languages are one-to-one, the job comes down to a lookup table: each mnemonic is replaced with its binary equivalent.
For example, the assembler sees LDA 5, looks LDA up in its table, finds the binary opcode 10000001, and produces the machine-code bytes 10000001 00000101.
A reads the whole high-level program once, translates the entire thing into machine code, and produces a standalone executable file that can be run later without the compiler being present.
How a compiler is used:
program.cpp).program.exe).An works through the high-level source line by line. After translating a line, it executes that line straight away before moving on to the next.
How an interpreter is used:
program.py).| Feature | Compiler | Interpreter |
|---|---|---|
| Translates... | The whole program in one go | One line at a time |
| Produces an executable? | Yes, a separate file | No |
| Runs the program? | No; the executable is run later | Yes; translates and runs in one step |
How a compiler works
Describing how a compiler translates (and reports errors) comes up often, so you need to know it translates the whole program at once into machine code, produces a standalone executable, and reports all errors together at the end — unlike an interpreter, it does not work line by line.
Identifying which translator is which
What comes up: a description ("converts and executes one line at a time", "creates an executable file") asks you to name the translator.
Watch out: match by the one defining property — interpreter = translates/executes one line at a time (stops at the first error); compiler = translates the whole program and produces an executable (all errors reported together); assembler = assembly language → machine code.
| Speed of execution | Fast (already in machine code) | Slower (translates as it runs, every time) |
| Reports errors... | At the end of compilation (or at the first one found that stops compilation) | Stops at the line where the error is found |
| Easier to debug? | Harder (must recompile after every change) | Easier (run, see error, fix, run again immediately) |
| Distribution | Easy; share the executable | Harder; the recipient also needs the interpreter |
| Source code visible to user? | No (only the executable is shared) | Yes (the source must be shared with the interpreter) |
| Typical use | Released, polished software | Active development and scripting |