In IB Computer Science HL, students are expected to understand how high-level code is translated into machine code. This means clearly distinguishing between interpreters, compilers, and Just-In-Time (JIT) compilation.
Many students confuse these terms or treat them as interchangeable. In IB exams, this leads to vague answers and lost marks. Each approach works differently and has distinct advantages and disadvantages.
Why Code Translation Is Needed
Computers do not understand high-level programming languages. All programs must eventually be converted into machine code before they can run.
The method used to perform this translation affects:
- Execution speed
- Error detection
- Portability
- Memory usage
This is why interpreters, compilers, and JIT systems exist.
What Is an Interpreter?
An interpreter translates and executes code line by line, one statement at a time.
How it works:
- Reads one line of source code
- Translates it into machine code
- Executes it immediately
- Moves to the next line
Key characteristics:
- No separate executable file
- Errors are reported one at a time
- Execution is slower than compiled code
Advantages:
- Easy debugging
- Platform independence (with the right interpreter)
