You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
This lesson covers the difference between high-level and low-level programming languages, including machine code and assembly language. This is part of OCR J277 Section 1.5.3.
A programming language is a formal language used to write instructions that a computer can execute. These instructions tell the computer what operations to perform.
Programming languages can be divided into two broad categories:
Low-level languages are closer to the binary instructions that the CPU directly understands. There are two types:
Machine code is the lowest-level programming language. It consists entirely of binary (1s and 0s) and is the only language the CPU can directly execute.
Example (simplified):
10110000 01100001
| Feature | Detail |
|---|---|
| Format | Pure binary (or sometimes hexadecimal) |
| Readability | Virtually impossible for humans to read |
| Portability | Not portable — specific to a particular CPU architecture |
| Speed | Fastest execution — no translation needed |
| Use | Rarely written directly; usually generated by translators |
Assembly language is a low-level language that uses mnemonics (short abbreviations) to represent machine code instructions. It is much easier to read than machine code but still very close to the hardware.
Example:
MOV AL, 61h ; Move the hexadecimal value 61 into register AL
ADD AL, 05h ; Add 5 to the value in register AL
HLT ; Halt the processor
| Feature | Detail |
|---|---|
| Format | Mnemonics (e.g. MOV, ADD, SUB, JMP, HLT) |
| Readability | Difficult but more readable than machine code |
| Portability | Not portable — specific to a CPU architecture |
| Translation | Requires an assembler to convert to machine code |
| Use | Device drivers, embedded systems, performance-critical code |
High-level languages use syntax that is closer to human language and mathematical notation. They are designed to be easier to read, write, and maintain.
| Language | Common Use |
|---|---|
| Python | Education, data science, web development, scripting |
| Java | Enterprise applications, Android apps |
| C# | Windows applications, game development (Unity) |
| JavaScript | Web development (front-end and back-end) |
| C++ | Games, operating systems, performance-critical applications |
name = input("What is your name? ")
print(f"Hello, {name}! Welcome to Computer Science.")
total = 0
for i in range(1, 11):
total += i
print(f"The sum of numbers 1 to 10 is: {total}")
| Feature | Detail |
|---|---|
| Readability | Easy to read and understand |
| Portability | Portable — can run on different hardware/OS with the right translator |
| Translation | Must be translated to machine code using a compiler or interpreter |
| Productivity | Programmers can write code faster |
| Abstraction | Hides hardware details; programmer focuses on the problem, not the hardware |
The diagram below positions each language family on the abstraction ladder, from human-readable code at the top down to raw binary executed by the CPU:
graph TD
HLL["High-Level Languages<br/>(Python, Java, C#, JavaScript)"]
ASM["Assembly Language<br/>(MOV, ADD, JMP mnemonics)"]
MC["Machine Code<br/>(binary 1s and 0s)"]
CPU["CPU executes"]
HLL -->|compiler or interpreter| MC
ASM -->|assembler<br/>(one-to-one)| MC
MC --> CPU
| Feature | High-Level | Low-Level |
|---|---|---|
| Readability | Easy to read and write | Difficult to read and write |
| Portability | Portable across different systems | Specific to one type of CPU |
| Translation | Needs compiler or interpreter | Needs assembler (or none for machine code) |
| Execution speed | Slower (must be translated first) | Faster (closer to/is machine code) |
| Hardware control | Limited direct hardware control | Direct control of hardware and memory |
| Debugging | Easier to find and fix errors | Harder to debug |
| Development time | Faster to develop programs | Slower to develop programs |
| Use cases | Most software applications | Device drivers, embedded systems, real-time systems |
OCR Exam Tip: If asked "Why might a programmer choose a low-level language?", good answers include: direct hardware control, faster execution, smaller program size — useful for embedded systems and device drivers.
| Situation | Best Choice | Reason |
|---|---|---|
| Writing a school project | High-level (Python) | Easy to learn and debug |
| Programming a pacemaker | Low-level (assembly) | Needs precise hardware control and speed |
| Developing a web application | High-level (JavaScript/Python) | Productivity and portability |
| Writing a device driver | Low-level (assembly/C) | Needs direct hardware access |
| Creating a mobile app | High-level (Java/Swift) | Cross-platform support, faster development |
Key Vocabulary: machine code, assembly language, mnemonic, high-level, low-level, portable, abstraction, compiler, interpreter, assembler.
To appreciate the gap between high-level and low-level languages, consider the simple task of adding two numbers and storing the result. Below the same job is expressed in Python (high-level), x86 assembly (low-level mnemonics) and a sketch of the resulting machine code.
Python (high-level):
a = 7
b = 5
total = a + b
print(total)
Four lines, entirely readable. The programmer does not need to know which CPU register stores which value, where in RAM the variables live, or how the screen is updated — the interpreter handles all of that. The level of abstraction is high.
x86 assembly (low-level mnemonics):
MOV AL, 7 ; load 7 into register AL
MOV BL, 5 ; load 5 into register BL
ADD AL, BL ; add BL to AL; result is stored in AL
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.