SLIDE 1
CSZone.co.uk
Click to reveal · Arrow keys also work
OCR J277 · Component 2 · Topic 2.5.1

Programming
Languages

High-level · Low-level · Translators · Compiler vs Interpreter

CSZone OCR GCSE Computer Science J277
Learning Objectives

By the end of this video you will be able to...

Explain the difference between high-level and low-level programming languages — including machine code and assembly language — and describe what is meant by a language being "closer to the hardware" or "closer to human language"
Compare the advantages and disadvantages of high-level and low-level languages in terms of readability, speed of execution, portability, and ease of development — and recommend the appropriate language type for a given scenario
Explain why translators are needed — the fundamental problem that CPUs only understand machine code (binary), and that all high-level programs must be converted before they can run
Describe how a compiler works — translating the entire source code into an executable file in one go — and state its advantages and disadvantages compared to an interpreter
Describe how an interpreter works — translating and executing source code line by line — and state its advantages and disadvantages compared to a compiler
⚡ Note: assemblers are NOT required for OCR J277. Only compilers and interpreters are assessed.
Programming Languages

What is a programming language?

DEFINITION
A programming language is a formal set of instructions that can be used to produce programs. Languages exist on a spectrum from low-level (close to the hardware, using binary or mnemonics) to high-level (close to human language, using English-like syntax).
The level of a language describes how close it is to machine code (binary). Low-level = very close to hardware. High-level = far from hardware, closer to the way humans think about problems
All computers ultimately only understand machine code — pure binary (0s and 1s). Every other language must eventually be converted into machine code before the CPU can execute it
THE LANGUAGE SPECTRUM
Machine Codee.g. 10110000 01100001LOWEST LEVEL
Assembly Languagee.g. MOV AL, 61hLOW-LEVEL
High-Level Languagee.g. print("Hello")HIGH-LEVEL
WHY DO DIFFERENT LEVELS EXIST?
Originally, all programs had to be written in machine code — pure binary. This was extremely time-consuming and error-prone. Assembly language was created as a first improvement, using short text codes (mnemonics). Then high-level languages were developed to make programming accessible to far more people and to allow much faster software development.
Higher-level languages abstract away hardware details — the programmer doesn't need to know how registers or memory addresses work. This is called abstraction
KEY PRINCIPLE
The higher the language level, the easier it is for humans to read and write — but the more translation work is needed before the CPU can run it. The lower the level, the harder it is to write — but it runs faster and gives more direct hardware control.
Low-Level: Machine Code

Machine code — the lowest level

DEFINITION
Machine code is the only language the CPU understands directly. It consists entirely of binary digits (0s and 1s). Each instruction is a pattern of bits that the processor interprets as a specific operation — such as adding two values, moving data, or jumping to a different part of the program.
EXAMPLE — MACHINE CODE
10110000 01100001 ; move value 97 into register 11000011 ; return 00000001 11000011 ; add two registers 01001000 10001001 ; store result in memory
ADVANTAGE
Fastest possible execution — the CPU understands machine code natively. There is zero translation overhead at runtime. The processor executes each instruction immediately. This is why time-critical systems (real-time controllers, device drivers) must be written at low level.
DISADVANTAGES
Extremely hard to read and write — a human cannot meaningfully understand long sequences of 0s and 1s without translation. A simple task requires dozens of binary instructions
Very hard to debug — identifying an error inside binary sequences is impractical without specialised tools
Not portable — machine code is specific to one CPU architecture. Code written for one processor will not run on a different processor type
WHEN IS MACHINE CODE USED?
Machine code is the final output that the CPU always executes — whether a program was originally written in Python, Java, or C. Today, programmers almost never write machine code directly. It is generated automatically by compilers from higher-level languages.
Low-Level: Assembly Language

Assembly language — mnemonics

DEFINITION
Assembly language is a low-level language that replaces binary machine code instructions with short text codes called mnemonics (pronounced neh-MON-iks). Each mnemonic corresponds to exactly one machine code instruction. Assembly language is easier to read than machine code, but still considered low-level — it remains very close to the hardware and is specific to a particular processor architecture.
EXAMPLE — ASSEMBLY LANGUAGE (illustrative)
MOV R1, #10 ; store 10 in register R1 MOV R2, #5 ; store 5 in register R2 ADD R3, R1, R2 ; R3 = R1 + R2 (= 15) STR R3, 200 ; store result at address 200
ADVANTAGES OVER MACHINE CODE
MOV, ADD, SUB, STR — these mnemonics are far more memorable than binary patterns. A programmer can at least read the intent of each instruction. Direct hardware control is preserved. Assembly is used in embedded systems and device drivers where speed and precision matter.
MACHINE CODE vs ASSEMBLY — COMPARISON
Feature Machine Code Assembly
ReadabilityVery poorPoor–fair
CPU executionDirectAfter translation
Uses binary?Yes — only 0s/1sNo — mnemonics
Hardware-specific?YesYes
Ease of writingExtremely hardHard
Both machine code and assembly are hardware-specific. Assembly code written for one processor type will not run unchanged on a different processor architecture.
KEY POINT
Both machine code and assembly are low-level languages. They require detailed knowledge of the hardware. Despite assembly being more readable than machine code, it is still far more difficult to use than a high-level language. Most modern software is written in high-level languages.
High-Level Languages

High-level languages — closer to human language

DEFINITION
A high-level language uses English-like syntax that is easy for humans to read, write, and understand. A single line of high-level code can represent tens or hundreds of machine code instructions. High-level languages abstract away the underlying hardware — the programmer doesn't need to know about registers, memory addresses, or processor architecture.
EXAMPLES
# Python — high-level for i in range(1, 11): print(i * 2) // JavaScript — high-level let name = "Alice"; console.log("Hello, " + name);
EXAMPLES OF HIGH-LEVEL LANGUAGES
Python Java JavaScript C# C++ PHP
ADVANTAGES OF HIGH-LEVEL LANGUAGES
Easier to read, write, and debug — English-like syntax is intuitive. Errors are much easier to spot
Portable — the same source code can run on different hardware and operating systems (with an appropriate translator)
Faster to develop — one line of code does the work of many machine code instructions
Abstraction — the programmer doesn't need to know about hardware registers or memory addresses
DISADVANTAGES
Slower execution — code must be translated to machine code before the CPU can run it. Low-level code always executes faster
Less direct hardware control — cannot directly access specific registers or memory addresses without specialist libraries
Comparison

High-level vs low-level — side by side

COMPARISON TABLE
Feature Low-Level High-Level
ReadabilityPoorExcellent
Execution speedVery fastSlower
PortabilityNot portablePortable
Development speedSlowFast
Hardware controlDirectAbstracted
Ease of debuggingVery hardEasy
WHEN TO USE LOW-LEVEL
Low-level languages are used when execution speed is critical or when direct hardware control is required — for example, in embedded systems (washing machines, car engine controllers), device drivers, operating system kernels, and real-time systems.
WHEN TO USE HIGH-LEVEL
High-level languages are used for the vast majority of software development — websites, apps, games, business software — where development speed, maintainability, and portability matter more than raw execution speed. Most students learn to program in a high-level language.
THE SAME TASK IN BOTH LANGUAGES
HIGH-LEVEL (Python) — add two numbers
result = 5 + 3 print(result)
LOW-LEVEL (Assembly) — same task
MOV R1, #5 ; load 5 MOV R2, #3 ; load 3 ADD R3, R1, R2 ; add → R3 = 8 STR R3, output ; store result
⚡ The high-level version is 2 lines and instantly readable. The assembly version is 4 lines for the same task — and this is a trivially simple example. Real programs involve thousands of instructions — which is why high-level languages dominate modern software development.
Translators

Why translators are needed

THE FUNDAMENTAL PROBLEM
A CPU can only execute machine code — pure binary. It cannot directly run Python, Java, C#, or any other high-level language. When a programmer writes code in a high-level language, that code must first be translated into machine code before the processor can execute it. The software that performs this translation is called a translator.
Source code = the original program written by a programmer in a high-level (or assembly) language
Object code / machine code = the translated binary output that the CPU can actually execute
THE TRANSLATION PROCESS
SOURCE CODE
Python / Java / C#
TRANSLATOR
Compiler / Interpreter
MACHINE CODE
0s and 1s
CPU
Executes
TWO TYPES OF TRANSLATOR
COMPILER
Translates the entire source code into machine code all at once, producing a standalone executable file. Translation happens once, before the program runs.
INTERPRETER
Translates and executes source code line by line. No output file is created. Translation happens every time the program runs.
Note: assemblers (which translate assembly language) are NOT required for OCR J277. Only compilers and interpreters are assessed.
KEY VOCAB
Source code — program written by a programmer in a high-level language.
Object code — machine code output produced by a compiler.
Translator — software that converts source code into machine code.
Translator: Compiler

The compiler — translate once, run many times

HOW IT WORKS
A compiler takes the entire source code and translates it all in one go into machine code, producing a standalone executable file (object code). This translation happens once, before the program runs. The executable can then be run as many times as needed — without the compiler or the original source code.
COMPILER PROCESS
1Source code is fed to the compiler
2Compiler analyses ALL of the code and checks for errors
3If errors found → reported all at once
4If no errors → produces executable file (.exe)
5Executable runs without the compiler — any time
ADVANTAGES
Faster execution — already translated; no overhead at runtime
Source code not needed to run — protects intellectual property
Translated only once — can be distributed and run repeatedly
DISADVANTAGES
Errors only shown after full translation — can't run any of the code until all errors are fixed. This slows down the development cycle

Slower development loop — must compile before every test

Platform-specific — compiled code is usually specific to an operating system or processor type; may need to be recompiled for different platforms
REAL-WORLD EXAMPLES
C / C++ Java (to bytecode) C# (.NET)
EXAM TIP — FASTEST REASON
If asked "why do compiled programs run faster?" — the answer is: the code has already been translated into machine code. There is no translation overhead at runtime. The CPU executes the machine code directly.
Translator: Interpreter

The interpreter — translate and execute line by line

HOW IT WORKS
An interpreter translates and executes source code one line at a time. It reads one instruction, translates it to machine code, executes it, then moves to the next. No output file is created. Every time the program is run, the interpreter must translate the code again from the beginning.
INTERPRETER PROCESS
1Read Line 1 of source code
2Translate line 1 → machine code
3Execute line 1 immediately
4Move to Line 2 — repeat until error or end
!Error on any line → stop immediately, report that line
ADVANTAGES
Errors reported immediately — stops at the exact line causing the error, making it easy to locate and fix problems
Easier to debug — you know which line failed
No compile step — faster development cycle; run and test immediately
DISADVANTAGES
Slower execution — translation happens at the same time as execution, every time the program runs

Source code must be present — the interpreter and source code are needed every time, which means source code must be distributed. This is a security concern (exposes intellectual property)

Translated every time — no caching or reuse of translated output
REAL-WORLD EXAMPLES
Python JavaScript PHP
WHY INTERPRETERS ARE GOOD FOR LEARNING
Interpreters (like Python's) are ideal for beginners and development because you can run code immediately and see errors with exact line numbers. This is why Python — an interpreted language — is the most popular language for learning to code.
Exam Practice

Programming languages — exam questions

Question 1 — 1 mark
State one advantage of using a high-level language over a low-level language.
Answer — Q1
Accept any one of:
• High-level languages are easier to read/write/understand (English-like syntax) [1]
• High-level languages are portable — can run on different hardware [1]
• High-level languages are faster to develop [1]
• High-level languages are easier to debug [1]
Question 2 — 2 marks
Give two differences between a compiler and an interpreter.
Answer — Q2
Accept any two of:
• A compiler translates all the code at once / an interpreter translates line by line [1]
• A compiler produces an executable file / an interpreter does not [1]
• Compiled programs run faster / interpreted programs run slower [1]
• A compiler reports errors after translation / an interpreter reports errors at the line they occur [1]
• Source code is not needed to run a compiled program / source code must be present for an interpreter [1]
Question 3 — 4 marks
A software company is deciding whether to use a compiler or an interpreter to translate their new program.

(a) Describe one advantage of using a compiler. [1]
(b) Describe one advantage of using an interpreter. [1]
(c) The company wants to protect their source code from being read by end users. State which type of translator they should use and explain why. [2]
Exam Answers

Question 3 — mark scheme

MARK SCHEME
(a) The compiled program will run faster (as it has already been translated into machine code / there is no translation overhead at runtime) [1]
OR: the source code does not need to be distributed / end users cannot see the source code [1]

(b) Errors are reported immediately at the line they occur / easier to find and fix errors during development [1]
OR: no compilation step needed / program can be run and tested immediately [1]

(c) They should use a compiler [1]. A compiled program runs from an executable file; the source code is not needed to run the program and therefore cannot be read by end users [1]
MARKING POINT
For part (c), two marks are awarded separately — one for naming the correct translator (compiler) and one for the explanation. Both must be present to score full marks.
COMPILER vs INTERPRETER — FULL REFERENCE
Feature Compiler Interpreter
Translation methodAll at onceLine by line
Output fileYes — executableNo
Runtime speedFasterSlower
Error reportingAfter full translationAt the failing line
Source code to run?Not neededAlways needed
Re-translates each run?No — once onlyYes — every run
EXAM STRATEGY
When asked to compare compiler and interpreter, always give a paired comparison — say what the compiler does AND what the interpreter does differently in the same point. e.g. "A compiler translates all the code at once whereas an interpreter translates it line by line."
HIGH vs LOW — QUICK MEMORY
Low-level: fast, hardware-specific, hard to read. High-level: readable, portable, slower. Compiler: all at once, executable, fast runtime. Interpreter: line by line, no output file, easy debugging.
Common Mistakes

Common mistakes — avoid these in the exam

MISTAKE 1 — Saying compiled programs run faster "because the computer is faster"
Students write "compiled programs run faster because the computer has more processing power." This is wrong. The speed advantage comes from the fact that the code has already been translated — there is no translation happening at runtime. The CPU receives pure machine code and executes it directly with no overhead
✓ Compiled programs run faster because the code is already in machine code — no translation is needed at runtime
MISTAKE 2 — Confusing "portable" with physical portability
Students say high-level languages are portable because "you can put them on a USB stick." Portability in programming means the same source code can run on different types of hardware and operating systems without rewriting it. Low-level code is not portable because it is written for a specific processor architecture
✓ Portable = same source code works on different hardware/OS platforms (with a suitable translator)
MISTAKE 3 — Saying interpreters produce an executable file
Students say "an interpreter produces an executable file that can be run." Interpreters do not produce any output file. They translate and execute each line immediately and then discard it. Every time the program runs, the interpreter must re-translate the source code from scratch. Only compilers produce executable files
✓ Compiler → produces an executable file. Interpreter → no output file is produced
MISTAKE 4 — Saying assembly language is the same as machine code
Students write "low-level means binary / machine code" and miss that assembly language is a separate low-level language. Machine code uses only 0s and 1s. Assembly language uses mnemonics (short text codes like MOV, ADD, SUB). Both are low-level, but they are different. Assembly still needs to be translated before the CPU can execute it
✓ Machine code = binary only. Assembly language = mnemonics. Both are low-level but different things
Summary

Key points — 2.5.1

Languages exist on a spectrum from low-level (close to hardware) to high-level (close to human language). Machine code is pure binary — the only language the CPU understands directly. Assembly language uses mnemonics. Both are low-level and hardware-specific
High-level languages (Python, Java, C#) use English-like syntax. They are easier to read, write, and debug; portable across hardware; and faster to develop. Disadvantage: slower execution and less direct hardware control than low-level
All high-level programs must be translated into machine code before the CPU can run them. The software that does this is a translator. There are two types assessed at GCSE: compiler and interpreter. Assemblers are NOT on the OCR J277 spec
A compiler translates the entire source code into an executable file all at once. Programs run faster (no runtime translation). Source code not needed to distribute. Errors only reported after full compilation
An interpreter translates and executes code line by line — no executable file created. Slower at runtime. Errors reported immediately at the failing line — easier to debug. Source code must always be present
⚡ Next topic: 2.5.2 — IDEs. Tools and facilities provided by an Integrated Development Environment.
2.5.1 Complete

Programming
Languages

Get the full resource pack at CSZone.co.uk

📄
Marked Worksheet
CSZone.co.uk
Quiz
CSZone.co.uk
📊
Slides
CSZone.co.uk
Next Up
2.5.2 — IDEs