What you'll learn
Programs are written in languages that people can read, but computers can only execute binary machine code. In OCR GCSE Computer Science (J277, section 2.5) you need to know the characteristics and purpose of high-level and low-level languages, why translators are needed, the differences between compilers and interpreters (and the role of assemblers), and the common tools and facilities of an integrated development environment (IDE), including the editor, error diagnostics, run-time environment and translators. This guide explains each and shows how to answer comparison questions accurately.
Exam questions usually ask you to compare compilers and interpreters, give a reason to use a low-level language, or describe IDE features that help a programmer find and fix errors.
Key terms and definitions
High-level language — A programming language that uses English-like keywords and is independent of the hardware, such as Python, Java or C#.
Low-level language — A language closely related to the hardware: machine code (binary) or assembly language (mnemonics).
Machine code — Binary instructions that the CPU can execute directly.
Assembly language — A low-level language that uses short mnemonics (such as LDA, ADD, STA) to represent machine code instructions.
Translator — A program that converts code written in one language into another, usually into machine code.
Compiler — Translates the whole of a high-level program into machine code in one go, producing an executable file.
Interpreter — Translates and runs a high-level program one line at a time.
Assembler — Translates assembly language into machine code.
Source code — The program as written by the programmer.
Object code / executable — The translated machine code produced by a compiler.
IDE (integrated development environment) — Software that provides tools to help programmers write, test and debug code.
Core concepts
High-level languages
High-level languages are designed to be easy for people to read, write and understand.
- They use English-like keywords (
if,while,print) and familiar mathematical notation. - One high-level statement may translate into many machine code instructions.
- They are portable: the same program can run on different types of processor, once translated for each.
- They include features such as variables, data structures, loops and sub-programs that make complex programs manageable.
- They are quicker to write and easier to debug and maintain.
However, the programmer has less direct control over how the hardware is used, and translated programs may be less efficient than carefully written low-level code.
Low-level languages
Machine code is the binary the CPU executes directly. It is extremely hard for people to read or write.
Assembly language uses mnemonics — short codes for each machine instruction — so it is easier than raw binary, but each line still corresponds to roughly one machine instruction.
Low-level languages:
- give direct control over hardware, such as specific memory locations and registers;
- can produce fast, memory-efficient programs;
- are useful for embedded systems, device drivers and parts of operating systems where speed and memory are critical;
- are specific to one type of processor, so not portable;
- are hard to write, read and debug, and programs take longer to produce.
Why translators are needed
The CPU only understands machine code. Any program written in a high-level language or in assembly language must be translated into machine code before it can be executed. There are three types of translator: compilers, interpreters and assemblers.
Compilers
A compiler translates the entire source code into machine code before the program is run, producing an executable file.
- The executable can be run many times without translating again, so it runs quickly.
- The executable can be distributed without revealing the source code, protecting the programmer's work.
- Users do not need the compiler to run the program.
- Errors are reported after the whole program has been checked, as a list; the program will not compile while there are syntax errors, which can make debugging slower.
- Compiling a large program can take time, and the executable only runs on the type of processor it was compiled for.
Interpreters
An interpreter translates and executes the source code one line at a time, each time the program runs.
- Errors are reported as soon as they are reached, and execution stops at that line, making it easy to find and fix problems — useful while developing and learning.
- The program can be run immediately, without waiting for compilation.
- The program runs more slowly, because each line is translated every time it is executed (including every time round a loop).
- Users need the interpreter installed, and the source code must be distributed, so others can see and copy it.
Comparing compilers and interpreters
| Compiler | Interpreter | |
|---|---|---|
| Translation | Whole program at once | One line at a time |
| Output | Executable file | No executable file |
| Speed of execution | Fast | Slower |
| Errors | Reported together after compiling | Reported line by line; stops at the first |
| Distribution | Executable only; source code hidden | Needs source code and interpreter |
| Best for | Finished, distributed programs | Development and testing |
Many programmers use an interpreter while developing and testing, then compile the finished program for distribution.
Assemblers
An assembler translates assembly language into machine code. Because each mnemonic corresponds to one machine instruction, translation is direct.
The integrated development environment
An IDE brings together the tools a programmer needs in one application. OCR expects you to know these:
Editor — where source code is written and changed. Features include:
- syntax highlighting, colouring keywords, strings and comments so errors stand out;
- automatic indentation and line numbers;
- auto-completion of keywords and variable names;
- bracket matching.
Error diagnostics — tools that help find and fix errors:
- error messages that identify the line number and type of error;
- highlighting of syntax errors as code is typed;
- debugging tools such as breakpoints, which pause the program at a chosen line, stepping through code one line at a time, and variable watch windows that show values as the program runs — making logic errors easier to find.
Run-time environment — allows the program to be run and tested within the IDE, showing output and errors as it runs, sometimes in a simulated environment.
Translators — the IDE includes a compiler and/or interpreter so the code can be translated and run directly.
These features make programmers more productive and help them write correct code more quickly.
Choosing a language and translator for a project
In practice, the choice depends on the task:
- A mobile app or website — a high-level language, because development is faster, code is easier to maintain by a team, and it can be translated for different devices.
- A device driver or the code for a small embedded controller — a low-level language, or carefully written high-level code, because direct hardware control and small, fast code matter most.
- A beginner learning to program — an interpreted high-level language, because errors are reported immediately at the line where they occur.
- A commercial game sold to customers — compiled, so it runs quickly and the source code is not shared.
How translation fits into development
A typical cycle is: write source code in the IDE's editor → translate it (interpret to test quickly, or compile) → read the error diagnostics → fix syntax errors → run and test → use debugging tools to find logic errors → repeat. Once the program works, a compiler produces the final executable for distribution. Understanding this cycle helps you explain why each IDE tool exists: every tool saves time at one of these steps.
Worked examples
Example 1: Comparing translators
Give two reasons why a software company would compile its program before selling it. (2 marks)
Answer: Customers can run the executable without needing a translator, and it runs quickly because it is already translated (1). The source code is not distributed, so competitors cannot easily copy or change it (1).
Example 2: Choosing an interpreter
Explain why an interpreter is useful while a student is writing and testing a program. (2 marks)
Answer: The interpreter stops at the line where an error occurs (1), so the student can see exactly where the problem is and fix it immediately before running again (1).
Example 3: Low-level languages
A programmer is writing software for a washing machine's control chip with very little memory. Explain why they might use a low-level language. (2 marks)
Answer: Low-level code gives direct control over the hardware and memory (1), so the program can be made small and efficient enough to fit the limited memory and run quickly (1).
Example 4: IDE features
Describe two features of an IDE that help a programmer find logic errors. (4 marks)
Answer: Breakpoints (1) pause the program at a chosen line so the programmer can check what has happened so far (1). A variable watch window (1) shows the values of variables as the program runs, so the programmer can see when a value becomes incorrect (1).
Common mistakes and how to avoid them
- Saying interpreters produce an executable. Only compilers do.
- Saying compiled programs are slower. They run faster; it is the compiling step that takes time.
- Calling assembly language "high-level". It is low-level, using mnemonics.
- Listing IDE features without explaining their use. Say how each helps.
- Saying high-level languages are run directly by the CPU. They must be translated.
Exam technique for "Translators and Facilities of Languages"
- For compiler/interpreter questions, use matching criteria: how they translate, speed, error reporting and distribution.
- For IDE questions, name the feature, then explain how it helps the programmer.
- For high- vs low-level questions, mention readability, portability, control over hardware and efficiency.
Quick revision summary
- High-level languages: English-like, portable, easier to write and debug; must be translated.
- Low-level languages: machine code and assembly; direct hardware control, efficient, processor-specific, hard to write.
- Compiler: whole program → executable; fast to run; source hidden; errors listed after compiling.
- Interpreter: line by line; stops at errors; slower; source code needed.
- Assembler: assembly → machine code.
- IDE: editor (syntax highlighting, auto-indent, auto-complete), error diagnostics (breakpoints, stepping, variable watch), run-time environment, translators.