OCR · GCSE · Computer Science

    Course version: J277 · Version from Sept 2022

    Languages: The purpose of translators

    A translator converts source code written by a programmer into a form that a computer can execute.

    Checked against the OCR J277 specification on .

    • Point 2 of 3
    • 4 key terms

    Study notes

    From the checked teaching notes for this specification point.

    The idea

    A translator converts source code written by a programmer into a form that a computer can execute. The three main types are assemblers, compilers and interpreters. An assembler translates assembly language mnemonics into machine code. A compiler translates a whole high-level program into machine code before it runs, producing an executable file; this can allow optimisation and means the user does not need the source code or translator at run time. An interpreter translates and executes source code line by line, which helps with debugging because errors are reported as they are encountered, but it can be slower at run time. The purpose of any translator is to bridge the gap between human-readable code and the binary instructions a processor can carry out, while also detecting syntax errors.

    What earns the marks

    • Translators convert source code into machine code or an intermediate form that can be executed by a computer.
    • An assembler translates assembly language into machine code, matching mnemonics to the processor instruction set.
    • A compiler translates an entire high-level program in one go and produces an executable file that can be run without the translator present.
    • An interpreter translates and executes source code one statement at a time, which can make debugging easier because errors are reported close to where they occur.
    • Translators detect and report syntax errors in source code, helping programmers correct mistakes before or during execution.
    • The choice of translator affects factors such as execution speed, ease of debugging and whether source code must be distributed.

    Common mistakes and how to put them right

    • Saying a compiler runs the program line by line.

      Put it right: A compiler translates the whole program before execution, whereas an interpreter translates and executes line by line.

    • Confusing an assembler with a compiler.

      Put it right: An assembler translates assembly language into machine code, while a compiler translates a high-level language into machine code.

    • Claiming an interpreter produces a standalone executable file.

      Put it right: An interpreter typically executes source code directly and does not usually create a separate executable.

    Exam tips

    • Name the translator type and state what it translates from and to, for example assembly language to machine code.
    • When discussing debugging, link interpreters to line-by-line error reporting and compilers to error reports after translating the whole program.
    • Use a scenario such as developing a program or distributing software to justify why one translator might be preferred over another.

    Try the lesson

    The start of the Languages: The purpose of translators lesson, made from checked teaching notes for this specification point.

    Have a go first

    What is the main purpose of a translator in computer science?

    Listen

    A translator converts source code written by a programmer into a form that a computer can execute. The three main types are assemblers, compilers and interpreters. An assembler translates assembly language mnemonics into machine code. A compiler translates a whole high-level program into machine code before it runs, producing an executable file; this can allow optimisation and means the user does not need the source code or translator at run time. An interpreter translates and executes source code line by line, which helps with debugging because errors are reported as they are encountered, but it can be slower at run time. The purpose of any translator is to bridge the gap between human-readable code and the binary instructions a processor can carry out, while also detecting syntax errors. A strong answer earns marks for these points. Translators convert source code into machine code or an intermediate form that can be executed by a computer. An assembler translates assembly language into machine code, matching mnemonics to the processor instruction set. A compiler translates an entire high-level program in one go and produces an executable file that can be run without the translator present. An interpreter translates and executes source code one statement at a time, which can make debugging easier because errors are reported close to where they occur. A common slip: saying a compiler runs the program line by line. Instead, a compiler translates the whole program before execution, whereas an interpreter translates and executes line by line. Exam tip: Name the translator type and state what it translates from and to, for example assembly language to machine code.

    See it

    A top-down flowchart. At the top, a node labelled 'Source code written by a programmer' points to a node labelled 'Translator'. The Translator node points to three outcomes: 'Form a computer can execute', 'Detects syntax errors', and three translator types. The three translator types are 'Assembler', 'Compiler' and 'Interpreter'. The Assembler node points to 'Assembly language mnemonics to machine code'. The Compiler node points to 'Whole high-level program to machine code before it runs', which points to 'Executable file'. The Interpreter node points to 'Translates and executes line by line'.
    Shows the purpose of a translator and the three main types: assembler, compiler and interpreter.

    Key words

    Say what each word means before you turn the card.

    Translator

    Try answering aloud or in your head before turning the card.

    Assembler

    Try answering aloud or in your head before turning the card.

    Compiler

    Try answering aloud or in your head before turning the card.

    Interpreter

    Try answering aloud or in your head before turning the card.

    See every definition
    Translator
    Converts source code written by a programmer into a form that a computer can execute, bridging human-readable code and binary instructions.
    Assembler
    Translates assembly language mnemonics into machine code, matching mnemonics to the processor instruction set.
    Compiler
    Translates a whole high-level program into machine code before it runs, producing an executable file that can be run without the translator present.
    Interpreter
    Translates and executes source code line by line, which helps with debugging because errors are reported as they are encountered.

    Label the diagram

    Some boxes have lost their names. Pick the right name for each number.

    The diagram again, with 3 boxes numbered instead of named. A top-down flowchart. At the top, a node labelled 'Source code written by a programmer' points to a node labelled 'Translator'. The Translator node points to three outcomes: 'Form a computer can execute', 'Detects syntax errors', and three translator types. The three translator types are 'Assembler', 'Compiler' and 'Interpreter'. The Assembler node points to 'Assembly language mnemonics to machine code'. The Compiler node points to 'Whole high-level program to machine code before it runs', which points to 'Executable file'. The Interpreter node points to 'Translates and executes line by line'.
    • 1Box 1

    • 2Box 2

    • 3Box 3

    0 of 3 labelled

    There is more to this lesson

    The full lesson goes on to check your understanding and help you earn the marks. Create a free account to carry on, with your progress saved.

    Carry on with the full lesson

    A week of Premium from your first lesson · Then the free plan continues · No card, no charge

    Test your understanding of Languages: The purpose of translators

    Active recall beats re-reading. Take an instant quiz now to test what you’ve learned and lock it into long-term memory.

    Take topic quiz

    A week of Premium from your first lesson · Then the free plan continues · No card, no charge