Skip to content
Cambridge AS & A Level9618

Language Translators

Computer Science 9618 Chapter Notes

Last updated November 2026

ShareWhatsAppPost

Language Translators notes as a printable PDF.

Read online free. Download a watermarked copy with a free account.

Read the notes

The full Language Translators notes as text: skim, search, and jump between subtopics.

~12 min read

1. Why a program needs translating

A computer runs machine code. A programmer writes in assembly language or in a high-level language. A translator converts the program the programmer wrote into a form the computer can run.

An assembler translates an assembly language program. A compiler translates a high-level language program. An interpreter translates and executes a high-level language program.

Worked example 12 marks

A computer programmer uses language translators. Two types of translator are an interpreter and a compiler. Explain why language translators are needed when programming.

  1. 1

    To convert a high-level language to a low-level language / machine code [1]

  2. 2

    Computers use machine code and programmers use high-level languages [1]

2. How a compiler and an interpreter work

A compiler attempts to translate the whole source code. It creates an error report at the end of the translation. If there are no errors, it creates an executable file.

An interpreter reads each line, translates it and executes it, before moving to the next line. It stops when an error is encountered. It does not store the program in executable format, so each line is translated again every time it runs, including lines inside a loop.

Examiner insight

“Some candidates applied descriptions more appropriate to the role of a compiler to this question, and others wrote long answers that did not address the whole question.”

Worked example 14 marks

A programmer uses language translators when writing and testing a program.

(a) Describe the operation of a compiler.

(b) Describe the operation of an interpreter.

  1. 1

    (a) Attempts to translate the whole source code [1]

  2. 2

    (a) If there are no errors, creates an executable file. Errors are reported at the end of the translation [1]

  3. 3

    (b) Reads each line, then translates it and executes it [1]

  4. 4

    (b) Stops when an error is encountered and displays the error where it finds it [1]

3. Compiler or interpreter: benefits, drawbacks and the choice

An interpreter suits writing and testing. Errors are shown one at a time, so the programmer can correct them in real time and carry on. Incomplete code can be run.

A compiler has drawbacks during development. A large program takes time to compile, the code must be recompiled when it changes, the program cannot run if there are errors, and one error can cause false reporting of further errors.

A compiler suits the finished program. It creates an executable file, so the program can be distributed without the source code and users do not need the translator.

To justify a choice, name the stage of development and give the reason.

Examiner insight

“Many of the responses simply described the operation of an interpreter without any comparison to a compiler.” “Vague answers such as “a compiler is faster” did not explain how or why it should be the translator of choice.”

Worked example 15 marks

A software developer is writing a computer program.

(a) The developer uses an interpreter while writing the program code because it is easier for debugging. Explain one reason why it is easier to debug the program code using an interpreter instead of a compiler.

(b) The program is ready to be sold to customers. The developer uses a compiler because it creates an executable file. Explain the reasons why the need to create an executable file makes the compiler the appropriate choice when the program is complete.

  1. 1

    (a) The interpreter will stop when an error is found [1]

  2. 2

    (a) … so the error can be corrected in real time and the result of the changes seen immediately [1]

  3. 3

    (b) The program can be distributed without source code [1]

  4. 4

    (b) … so it cannot be edited / stolen / plagiarised [1]

  5. 5

    (b) Users do not require the translator to run the program, so time is not spent retranslating [1]

4. Partly compiled, partly interpreted

Some high-level language programs are partially compiled and partially interpreted. Java (console mode) is the syllabus example.

The source code is compiled first to an intermediate code. The intermediate code is then interpreted when it is run, on several different platforms.

This gives two reasons. The program can be used on different platforms, because it is interpreted when run. The code is optimised for the CPU, because machine code is generated at run time.

This is not the same as using an interpreter during development and a compiler at the end.

Examiner insight

“There is a need for greater understanding of why some programs might be partially compiled and partially interpreted.” “The question refers to a situation where code in a high-level language is compiled first to an intermediate code which can then be interpreted on several different platforms.”

Worked example 12 marks

Compilers and interpreters translate programs written in a high-level language into a low-level language. Explain why high-level language programs might be partially compiled and partially interpreted.

  1. 1

    Partially compiled programs can be used on different platforms, as they are interpreted when run [1]

  2. 2

    The code is optimised for the CPU, as machine code is generated at run time [1]

5. An IDE: coding and presentation

An Integrated Development Environment (IDE) is used to write and test a program. Its features for coding include context-sensitive prompts, which help complete statements.

Its features for presentation include prettyprint, which identifies key terms, and expand and collapse of code blocks. Colour coding is credited alongside pretty printing.

Name the feature and say what it does for the programmer. Do not reword its name.

Examiner insight

“There was little or no distinction made between writing the code and running the program or which features would be used at each stage.” “A significant number of responses included features of an IDE which were not presentation features.”

Worked example 14 marks

A programmer uses language translators when writing and testing a program. Explain how a programmer can make use of a typical Integrated Development Environment (IDE) when writing and testing a program.

  1. 1

    Writing: context-sensitive prompts to help complete statements [1]

  2. 2

    Writing: pretty printing to identify key terms [1]

  3. 3

    Testing: single stepping to run the code line by line [1]

  4. 4

    Testing: breakpoints to stop the code at set points to check values [1]

6. An IDE: error detection and debugging

For initial error detection, an IDE offers dynamic syntax checks, made as the code is written.

For debugging, it offers single stepping, breakpoints and a report window that shows variables and expressions as the program runs.

Single stepping runs the code line by line. A breakpoint stops the code at a set point so the values can be checked. The report window shows how variables change.

Examiner insight

“Popular incorrect answers were context-sensitive prompts and pretty printing which are tools for coding rather than debugging.” “Many of the answers simply reworded the name of the feature, for example, “a breakpoint is a point at which the program breaks”.”

Worked example 12 marks

Jennifer uses an Integrated Development Environment (IDE) to write her computer program. Identify two debugging tools that a typical IDE can provide.

  1. 1

    Breakpoints [1]

  2. 2

    Single stepping [1]

Recap

  • Assembler: translates assembly language. Compiler: translates a high-level language program. Interpreter: translates and executes a high-level language program.
  • Compiler: translates the whole source code, reports errors at the end, creates an executable file if there are none.
  • Interpreter: translates and executes line by line, stops at an error, stores no executable file.
  • Interpreter for writing and testing: errors one at a time, corrected in real time, incomplete code can run.
  • Compiler for the finished program: executable file, no source code distributed, no translator needed by the user.
  • Partly compiled, partly interpreted: compiled first to intermediate code, then interpreted on several platforms.
  • IDE coding and presentation: context-sensitive prompts, prettyprint, expand and collapse code blocks.
  • IDE debugging: dynamic syntax checks, single stepping, breakpoints, report window.

End-of-chapter exercise

Test yourself on the whole chapter. Work through these before moving on.

  1. State the type of translator used for a program written in assembly language.1 mark
    Answer
    1. An assembler.

    Trap: A compiler translates a high-level language program, so it is the wrong translator for assembly language.

  2. A programmer writes a program in a high-level language. Explain why the program must be translated before the computer can run it.2 marks
    Answer
    1. Computers use machine code.
    2. The programmer wrote the program in a high-level language, so a translator must convert it.

    Trap: Describing what a compiler does with errors answers a different question from why a translator is needed.

  3. Describe how an interpreter runs a program.3 marks
    Answer
    1. It reads each line, then translates it and executes it.
    2. It moves to the next line only after the current line has run.
    3. It stops and displays the error when an error is encountered.

    Trap: Writing that the whole program is checked first and the errors are reported at the end describes a compiler.

  4. A compiler reports 14 errors in a program. Explain why the programmer cannot run any part of the program yet, and why fewer than 14 separate mistakes may need fixing.3 marks
    Answer
    1. The program cannot run if there are errors.
    2. The compiler reports all the errors at the same time, after translating the whole source code.
    3. One error can cause false reporting of further errors.

    Trap: Assuming that all 14 errors are separate mistakes. One error can cause several reports.

  5. A developer has only written the first part of a long program. State and justify the translator the developer should use to test that part.3 marks
    Answer
    1. An interpreter.
    2. Incomplete code can be tested and run.
    3. It stops when an error is found, so the error can be corrected in real time.

    Trap: Naming the translator and describing how it works earns little. The answer must be linked to the coding stage and give a reason.

  6. A company sells its finished program to customers. Justify the use of a compiler to produce the version the customers receive.3 marks
    Answer
    1. The compiler creates an executable file.
    2. The program can be distributed without the source code, so it cannot be edited or stolen.
    3. Customers do not need the translator, so no time is spent retranslating.

    Trap: “A compiler is faster” is too vague. Examiners reported that it does not explain why the compiler is the choice.

  7. A loop in a program runs 1 000 times. Explain why the loop runs more quickly from a compiled executable file than when the program is run by an interpreter.3 marks
    Answer
    1. An interpreter translates each line every time it is run, including lines inside a loop.
    2. So the loop body is translated 1 000 times.
    3. An executable file is already translated, so there is nothing to re-interpret.

    Trap: Saying that a compiler translates more quickly. The point is that the executable file is not translated again.

  8. A student says: “A language that is partly compiled and partly interpreted uses the interpreter while the program is written and the compiler when it is finished.” Explain why the student has misunderstood what “partly compiled and partly interpreted” means.3 marks
    Answer
    1. In such a language the source code is compiled first to an intermediate code.
    2. The intermediate code is then interpreted.
    3. It can be interpreted on several different platforms.

    Trap: The student describes using an interpreter in development and a compiler for release. Examiners reported this as the most common wrong answer.

  9. A team is writing a program of 50 000 lines. Each change to the code means the compiler must be run again before any test, and the first compilation reports 30 errors. When it is finished, the program will be sold to customers. Explain which translator the team should use at each stage of development, and why.6 marks
    Answer
    1. While writing the program: use an interpreter.
    2. It lets the team test and debug the partially completed program.
    3. It stops when an error is found, so the error is corrected in real time and only one error is shown at a time, with no dependent errors.
    4. When the program is complete: use a compiler.
    5. It creates an executable file, so the program can be distributed without the source code and cannot be edited or stolen.
    6. Customers do not need the translator, so no time is spent retranslating.

    Trap: Describing how each translator works without linking it to the coding stage or the finished program. Examiners reported many answers that did this.

  10. A program should output the total of 12 monthly readings. It compiles without errors but outputs the wrong total. ``` FOR Month ← 1 TO 12 Total ← 0 Total ← Total + Reading[Month] NEXT Month OUTPUT Total ``` (a) Explain why the compiler does not report this error. [1] (b) Describe how the programmer can use the debugging tools of a typical IDE to find the line that causes the error. [3] (c) `Reading[1]` is 40 and `Reading[2]` is 35. State the value of `Total` the report window shows at the end of the second pass of the loop, and the value it should show. [2]6 marks
    Answer
    1. (a) The rules of the language have not been broken: there are no syntax errors.
    2. (b) Set a breakpoint inside the loop to stop the code at that point.
    3. (b) Single step through the loop line by line.
    4. (b) Use the report window to see how `Total` changes: it is set back to 0 on every pass.
    5. (c) It shows 35, because `Total ← 0` runs before 35 is added.
    6. (c) It should show 40 + 35 = 75.

    Trap: Claiming the IDE will find and correct the error itself, or naming pretty printing or auto-complete: examiners reported both. The fault is a variable initialised inside the loop.

Say this, not that

Wording that loses the mark, against the wording the mark scheme credits.

Loses the markGets the mark
“An interpreter makes debugging easier.”The interpreter stops when an error is found, so it is corrected in real time and only one error is shown at a time.
“A compiler is faster.”The compiler creates an executable file, so users do not need the translator and no time is spent retranslating.
“A breakpoint is a point at which the program breaks.”A breakpoint stops the code at a set point so the values can be checked.
Pretty printing is a debugging tool.Pretty printing is a presentation feature. Debugging uses single stepping, breakpoints and the report window.

Frequently asked questions

What is the difference between a compiler and an interpreter?
A compiler attempts to translate the whole source code, reports errors at the end and, if there are no errors, creates an executable file. An interpreter reads each line, translates and executes it, and stops when an error is encountered. An interpreter does not store the program in executable format.
Why does an interpreter make debugging easier?
An interpreter stops when an error is found, so the error can be corrected in real time and the result of the changes seen immediately. Errors are shown one at a time, so the programmer can correct them and carry on. Incomplete code can also be run.
Why is a compiler used for the finished version of a program?
A compiler creates an executable file, so the program can be distributed without the source code and users do not need the translator. No time is spent retranslating the program each time it runs. An interpreter suits writing and testing, while a compiler suits the finished program.
What is a partly compiled, partly interpreted program?
The source code is compiled first to an intermediate code, which is then interpreted when it is run on several different platforms. Java in console mode is the syllabus example. Machine code is generated at run time, so the code is optimised for the CPU.
Which IDE tools help a programmer debug a program?
A typical IDE offers single stepping, which runs the code line by line, and breakpoints, which stop the code at a set point so the values can be checked. A report window shows variables and expressions as the program runs. Dynamic syntax checks find errors as the code is written.
Is pretty printing a debugging tool?
No. Pretty printing is a presentation feature that identifies key terms. Debugging uses single stepping, breakpoints and the report window. Examiners reported that context-sensitive prompts and pretty printing are tools for coding rather than debugging.

Free notes are just the start.

Unlock every Workbook and Chapter at a Glance, and generate your own worksheets and predicted papers.

Explore plans

Related chapters