Computer Science · Theme A: Concepts of computer science
A1.4 — Translation
Computer Science · SL / HL · syllabus-mapped notes
CS_A1.4.1
Interpreters and compilers
Weighing the two translation approaches, plus JIT and bytecode.
Full note — freeThis card is HL only. You must be able to evaluate the translation processes of interpreters and compilers : the two ways source code is turned into instructions a computer can run. Compiler : translates the whole program into machine code once, ahead of time, producing an executable that then runs directly. Interpreter : translates and executes the program one statement at a time, each run. Compare on these factors Error detection: a compiler reports errors for the whole program before it runs; an interpreter stops at the first error it reaches while running, which can make debugging more immediate. Translation time: compiling adds an up-front build step but then runs fast; interpreting has no build step but re-translates each line as it runs, so execution is slower. Portability: compiled machine code is tied to one platform, so it must be recompiled for each; interpreted source runs anywhere the interpreter exists, so it is more portable. Applicability: compilers suit finished, performance-critical software; interpreters suit interactive, quick-to-change work. In-between approaches Just-in-time (JIT) compilation : compiles code to machine code at run time, giving near-compiled speed while keeping flexibility. Bytecode interpreters : source is first compiled to portable bytecode , which a virtual machine then interprets (or JIT-compiles), combining portability with speed. Scenarios to consider (must include) Rapid development and testing: an interpreter's edit-run-debug loop with no build step is ideal. Performance-critical applications: a compiler (or JIT) is preferred for fast execution. Cross-platform development: interpreted source or bytecode runs on many platforms without recompiling. Judgement: compilers win on execution speed and whole-program error checking, interpreters win on portability and fast development, and hybrids (JIT, bytecode) aim to get both; the right choice depends on the scenario.
