Loading…
Loading…
Loading…
OCR GCSE Computer Science · J277
OCR J277 Check the specification (PDF) (opens in a new tab)
Programmers usually write instructions in a high-level language, such as Python. Its commands and notation make programs easier for people to write and understand. These written instructions are called source code.
A processor cannot directly execute Python commands. It executes machine code: instructions represented in binary, using 0s and 1s. There is therefore a gap between the language the programmer uses and the instructions the processor can execute.
A translator is a program that converts source code into machine code. Translation allows a programmer to use a human-readable language while still producing instructions that the processor can execute.
Translation bridges the gap between programmer-readable source code and the machine instructions a processor executes.
Translation preserves what the instructions tell the computer to do, while changing how those instructions are represented. It is not merely a matter of turning the letters of the source code into binary character codes: the result must be machine instructions that carry out the intended operations.
Consider the Python instruction print(2 + 3). A person can recognise that it asks the computer to add two numbers and display the result. The processor, however, cannot execute that Python text directly. Translation is needed so that machine-code instructions can carry out the calculation and produce the output.
This illustrates the key distinction: translation converts instructions; execution carries them out. A program being readable to a person does not make it directly executable by a processor.
Compilers and interpreters are types of translator used for high-level languages. They work differently, but both allow high-level program instructions to be carried out by a computer.
Assembly language also needs translation into machine code, using an assembler. Machine code itself does not need this translation because it is already in the form the processor executes.
Get unlimited access to all revision notes, key terms, and exam tips.
Translation: converts program instructions into machine code.
Execution: carries out the instructions.
Compilers and interpreters translate high-level languages; assemblers translate assembly language.
Get unlimited access to all revision notes, key terms, and exam tips.
When explaining why translation is needed, link both facts: the program is written in a high-level language, but the processor can only execute machine-code instructions.
Say that a translator converts source code into machine code, not simply that it ‘makes the code work’.
Machine code is binary, but not every binary file contains instructions that a processor can execute.
Translator
Software that translates program source code into machine code so that its instructions can be executed by a processor.
Source code
The program instructions written by a programmer in a programming language, before translation.
Machine code
Instructions represented in binary that a processor can execute directly.
High-level language
A programming language that uses human-readable commands and hides many details of the processor’s machine instructions.
Put your knowledge into practice — try past paper questions for Computer Science
Translator
Software that translates program source code into machine code so that its instructions can be executed by a processor.
Source code
The program instructions written by a programmer in a programming language, before translation.
Machine code
Instructions represented in binary that a processor can execute directly.
High-level language
A programming language that uses human-readable commands and hides many details of the processor’s machine instructions.