What are compilers, interpreters and assemblers, and how do they differ?
The purpose of translators, the characteristics of a compiler and an interpreter and how they differ, and the role of an assembler in translating assembly language.
An OCR J277 2.5.2 answer on translators: why source code must be translated, the characteristics of a compiler and an interpreter and how they differ, and the role of an assembler in translating assembly language to machine code.
Reviewed by: AI editorial process; not yet individually human-reviewed
Have a quick question? Jump to the Q&A page
Jump to a section
What this dot point is asking
OCR wants you to explain why translators are needed, the characteristics of a compiler and an interpreter and how they differ, and the role of an assembler. The most examined point is the compiler-versus-interpreter comparison: whole-program-at-once versus line-by-line. This is examined in Paper 2, often as a comparison.
Why translators are needed
Compilers
Interpreters
Assemblers
Try this
Q1. State what a translator does. [1 mark]
- Cue. Converts source code into another language, usually the machine code the CPU can execute.
Q2. State the key difference between how a compiler and an interpreter translate a program. [2 marks]
- Cue. A compiler translates the whole program into machine code in one go before it runs; an interpreter translates and executes it one line at a time, each time it runs.
Q3. State what an assembler translates. [1 mark]
- Cue. Assembly language into machine code.
Exam-style practice questions
Practice questions written in the style of OCR exam questions on this dot point, with worked answer explainers. The year tag is the paper they imitate, not the source.
OCR 20216 marksCompare a compiler and an interpreter. Your answer should explain how each translates a program and discuss an advantage and disadvantage of each.Show worked answer →
A 6-mark comparison, so explain each then compare.
Compiler: translates the whole source code into machine code in one go, before the program runs, producing an executable file. Advantages: the program then runs quickly without the translator, and the executable can be distributed without the source code. Disadvantages: compiling takes time before you can run, and errors are reported all together at the end of compilation, which can slow debugging; the executable is specific to one platform.
Interpreter: translates and executes the source code one line (statement) at a time, each time the program runs. Advantages: it runs the code immediately with no separate compile step, and it reports each error as it reaches it, which is helpful while developing. Disadvantages: it runs more slowly because translation happens every time it runs, and the source code (and an interpreter) is needed each time.
Markers reward the whole-at-once versus line-by-line distinction, and a genuine advantage and disadvantage of each, with a clear comparison.
OCR 20223 marksState what a translator is, name the three types, and state what an assembler translates.Show worked answer →
Translator (1): a program that converts source code written in one language into another language, usually into machine code that the CPU can execute.
Three types (1): compiler, interpreter and assembler.
Assembler (1): it translates assembly language (a low-level language using mnemonics) into machine code, usually one mnemonic to one machine-code instruction.
Markers reward the definition of a translator, the three correct types, and the assembler translating assembly language into machine code. Confusing the assembler with the compiler loses the last mark.
Related dot points
- The characteristics and purpose of high-level and low-level languages, the difference between machine code and assembly language, and the advantages and disadvantages of each level.
An OCR J277 2.5.1 answer on high-level and low-level languages: their characteristics and purpose, the difference between machine code and assembly language, and the advantages and disadvantages of programming at each level.
- The common tools and facilities available in an integrated development environment (IDE): the editor, error diagnostics, run-time environment and translators, and how each helps a programmer.
An OCR J277 2.5.2 answer on integrated development environments: what an IDE is and the common tools it provides (editor, error diagnostics and debugging, run-time environment and translators), and how each helps a programmer write and test code.
- How programming languages, source code, translators and integrated development environments fit together: why source code must be translated to machine code, and how the choice of language and tools supports writing software.
An OCR J277 2.5 answer tying the topic together: source code versus machine code, why translation is needed, how language level (high or low) is chosen, and how an IDE supports the whole process of writing, translating, running and debugging software.
- The two main types of programming error: syntax errors and logic errors, what causes each, how they are found, and how they differ.
An OCR J277 2.3.2 answer on the two main types of programming error: syntax errors (breaking the rules of the language) and logic errors (the program runs but gives the wrong result), what causes each, and how they are found and corrected.
- The purpose of the CPU and the fetch-decode-execute cycle, the von Neumann architecture, and the function of common CPU components (ALU, CU, cache, registers including the MAR, MDR, Program Counter and Accumulator).
An OCR J277 1.1.1 answer on the purpose of the CPU, the fetch-decode-execute cycle, the von Neumann architecture, and the function of the ALU, control unit, cache and the named registers (MAR, MDR, Program Counter, Accumulator).
Sources & how we know this
- OCR GCSE (9-1) Computer Science (J277) specification — OCR (2020)