Mission 1 · Spec 2.5.1
Languages and translators
High-level and low-level languages, why code must be translated, and the differences between compilers and interpreters.
- Starter 5 min
- Learn 10 min
- Lab 15 min
- Quiz 10 min
- Exam 10 min
Lost in translation
You can read print("Hello"). The CPU can only run binary instructions. Who or what bridges the gap?
Reveal
A translator: a compiler, interpreter or assembler converts code into machine code the CPU can execute.
Key ideas
High-level languages
Python, Java, C#: close to English, easier to write, read and debug; one statement may become many machine code instructions; portable between different processors.
Low-level languages
Machine code (binary) and assembly language (mnemonics). Direct control of hardware, fast and memory-efficient, but hard to write and specific to one processor type.
| Compiler | Interpreter | |
|---|---|---|
| How | Translates the whole program in one go | Translates and runs one line at a time |
| Output | Produces an executable file | No executable; needs the interpreter every time |
| Errors | Reported after the whole program is translated; nothing runs until all are fixed | Stops at the first error; lines before it have already run |
| Speed | Executable runs fast | Slower, as it translates while running |
| Best for | Distributing finished programs (source code stays private) | Developing and debugging |
Compiler vs interpreter race
High level or low level?
Exam-style questions
1. Explain why programs written in a high-level language need to be translated.
[2 marks]Mark scheme
- The CPU can only execute machine code / binary (1)
- so high-level code must be converted into machine code (1)
2. A developer is writing a game to sell. Explain why they would use a compiler to produce the final version.
[3 marks]Mark scheme
- A compiler produces an executable file (1)
- so customers can run it without a translator / the source code isn't shared, protecting it (1)
- The compiled program runs faster (1)
TUTOR NOTES
- Misconception: "compilers are faster". The compiled program runs faster; compiling takes time.
- Misconception: assembly language is machine code.
Mission 2 · Spec 2.5.2
The Integrated Development Environment
The tools an IDE provides to help programmers write, run and debug code.
- Starter 5 min
- Learn 10 min
- Lab 10 min
- Quiz 10 min
- Exam 10 min
Notepad vs IDE
You could write Python in Notepad. What would you miss compared with an IDE like IDLE, Thonny or VS Code?
Reveal
Colour-coded keywords, line numbers, auto-complete, error messages that point to the problem line, a Run button with an output window, and a debugger. An IDE puts all these tools in one place.
IDE features
Editor
Where code is written and edited, with line numbers, syntax highlighting, auto-indentation and auto-complete.
Error diagnostics
Identify errors and show where they are, e.g. highlighting the line and giving a message.
Run-time environment
Lets the program run inside the IDE and shows its output, so it can be tested.
Translators
A built-in compiler or interpreter to translate the code.
Debugging tools
Breakpoints to pause the program, stepping through line by line, and watching variable values.
IDE explorer
Click the feature described in the yellow box.Exam-style questions
1. Describe two features of an IDE that help a programmer find and fix errors.
[4 marks]Mark scheme
- Error diagnostics (1): highlight errors and show the line / give a message explaining the problem (1)
- Breakpoints (1): pause the program at a chosen line so variables can be checked (1)
- Stepping (1): run the program one line at a time to see where it goes wrong (1)
- Syntax highlighting (1): colour-codes keywords so typing errors stand out (1)
- Max 4
TUTOR NOTES
- Practical: have the student set a breakpoint in their own IDE and watch a loop variable change.
- Exam habit: name the feature, then say how it helps.