Revision Notes
IB DP Computer Science (DP Computer Science): Translation (HL) – Revision Notes
Condensed HL notes on translation for IB DP Computer Science A.1: compilers, interpreters, assemblers, bytecode, JIT, exam traps and a self-test.
- Subject
- Computer Science
- Level
- IB
- Topic
- A.1 – Computer fundamentals
- Author
- Marlbridge Academic Team
- Updated
- Reviewed by
- Harris Khan (what this means)
Aligned to International Baccalaureate IB Diploma Programme Computer Science (DP Computer Science), First assessment 2027. Official subject brief .
Syllabus page (what it covers and how it is assessed): IB Diploma Programme Computer Science.
Found an error? Report a correction.
Need help with this topic? Request a free trial class for IB Diploma Programme Computer Science (DP Computer Science (2014) / DP Computer Science (2027)).
Quick-recall notes for A1.4 Translation, an HL-only section of A.1 Computer fundamentals (IB DP Computer Science, first assessment 2027). For explanations and model answers, use the translation study guide; for the machine-code execution these notes build on, see the A.1 Computer fundamentals revision notes. Check the full guide for the exact outcomes.
Key terms
| Term | Meaning |
|---|---|
| Machine code | Binary instructions from a processor’s own instruction set |
| High-level language | Hardware-independent language with English-like keywords and structures |
| Assembly language | Low-level language using mnemonics, close to one per machine instruction |
| Translator | Program that converts source code into a form the machine can execute |
| Source code | The program as written by the programmer |
| Compiler | Translates the whole program into machine code before it runs |
| Executable (object code) | The compiled machine-code file |
| Interpreter | Translates and executes one statement at a time while the program runs |
| Assembler | Translates assembly language into machine code |
| Bytecode | Intermediate code produced by compiling source for a virtual machine |
| Virtual machine | Software that runs bytecode on the real hardware |
| Just-in-time (JIT) compilation | Compiling frequently used parts of bytecode to native code during execution |
| Portability | Ability of a program to run on different platforms |
Compiler versus interpreter
| Compiler | Interpreter | |
|---|---|---|
| When translated | Once, before running | Every run, statement by statement |
| Output | Executable | None |
| Run speed | Fast | Slower (loops re-translated) |
| Errors | All reported after analysis; no executable until fixed | Stops at first error met; shows the line |
| Development | Recompile after each change | Test changes immediately |
| User needs | Executable only | Interpreter plus source |
| Source protection | Yes | Usually no |
| Portability | Recompile per platform | Runs wherever the interpreter exists |
Assemblers
- Translate mnemonics (for example, load, add, store) into machine code.
- Roughly one-to-one: each line becomes one machine instruction.
- Output is specific to one processor family.
Bytecode and JIT in one chain
Source → compiled to bytecode → virtual machine runs bytecode → JIT compiles hot sections to native code → fast execution of those sections.
- Java: source compiled to bytecode; runs on the JVM, which uses JIT.
- Python (standard implementation): source compiled to bytecode automatically, then interpreted.
- Gain: portability (same bytecode on any platform with the VM) plus speed from JIT.
- Cost: slower start-up, extra memory, and the VM must be installed.
Choosing a translator
| Scenario | Best fit | Reason |
|---|---|---|
| Learning to program; frequent small changes | Interpreter | Immediate testing, clear error location |
| Selling a game or app | Compiler | Fast execution; source code not shared |
| Software for many different devices | Bytecode + VM | Same code runs anywhere a VM exists |
| Code for a specific microcontroller with tight timing | Assembler or compiler | Direct control over machine instructions |
Errors and when they appear
| Error type | Example | Found by |
|---|---|---|
| Syntax | Missing bracket or misspelt keyword | Compiler during syntax analysis, or interpreter when the line is reached |
| Runtime | Division by zero; file not found | Only when the program runs, whichever translator is used |
| Logic | Using < where <= was needed |
Neither translator; found by testing |
Compiler stages (outline)
Lexical analysis (tokens) → syntax analysis (grammar; syntax errors) → semantic analysis (meaning, types) → code generation → optimisation.
Exam traps
- Interpreters do not produce an executable.
- Compilation removes syntax errors, not logic errors or runtime errors.
- Bytecode is not machine code; it needs a virtual machine.
- JIT happens during execution, not before.
- An interpreter may miss errors in code that is never reached in a particular run.
- In “explain” questions, tie each feature to the scenario (development stage, distribution, performance, platforms).
Self-test
- Why can a CPU not execute high-level source code directly?
- State one advantage of a high-level language over assembly language.
- What does a compiler produce?
- Why does interpreted code containing a loop usually run more slowly than compiled code?
- Give one advantage of an interpreter during development.
- Why might a company prefer to distribute a compiled executable?
- What does an assembler translate?
- Define bytecode.
- Explain how bytecode makes a program portable.
- What is JIT compilation, and what does it improve?
- Name the compiler stage at which syntax errors are detected.
- Give one disadvantage of a compiled executable.
Answers:
- It can only execute machine code from its own instruction set; source code must be translated first.
- Any one: easier to read, write and maintain; uses structures such as loops and functions; largely independent of the hardware.
- An executable file of machine code (object code).
- Each statement is translated every time it is executed, so loop statements are translated on every iteration.
- Any one: changes run immediately without recompiling; it stops at the first error and shows the line.
- It runs fast, users do not need a translator, and the source code is not shared.
- Assembly language (mnemonics) into machine code.
- Intermediate code, produced by compiling source code, that is run by a virtual machine rather than directly by a processor.
- The same bytecode can run on any platform that has the virtual machine, so it does not need to be recompiled for each processor.
- Compiling frequently executed parts of a program into native machine code while it runs; it improves execution speed.
- Syntax analysis.
- Any one: it only runs on the platform it was compiled for; it must be recompiled after every change; compilation can take time.
Related pages
Official syllabus
International Baccalaureate Organization, Diploma Programme Subject Brief – Sciences: Computer science, first assessment 2027, © 2024.
Related resources
-
Study guides
IB DP Computer Science A.1: Computer Fundamentals
Study guide to A.1 Computer fundamentals in IB DP Computer Science (first assessment 2027): the CPU, the fetch-execute cycle, storage, binary data and the OS.
Computer Science · International Baccalaureate · IB
Read guide -
Practice questions
IB DP Computer Science A.1: Computer Fundamentals – Practice Questions
Twelve original questions on the CPU, fetch-execute, storage, binary, file sizes, a trace table and the OS for IB DP Computer Science A.1, with worked answers.
Computer Science · International Baccalaureate · IB
Try questions -
Revision notes
IB DP Computer Science A.1: Computer Fundamentals – Revision Notes
Recall notes on IB DP Computer Science A.1 Computer fundamentals: CPU registers, fetch-execute, storage, binary, hex, file sizes and the OS, with a self-test.
Computer Science · International Baccalaureate · IB
Revise topic
Get free revision emails (optional)
Occasional emails with practice questions, worked explanations and links to free resources for the qualification and subjects you choose. No spam, and you can unsubscribe from any email. The free tools on this site never need an email.