1. High-Level vs. Low-Level Languages
Programming languages are the tools we use to write instructions for a computer. They fall into two main categories. High-Level Languages (HLLs) like Python or Java use English-like commands and are easy for humans to read, write, and debug. They handle complex tasks with simple statements. Low-Level Languages (LLLs) are much closer to the computer's native language. This category includes Assembly Language and Machine Code (binary 1s and 0s). LLLs give programmers direct control over the hardware but are much harder to work with and are specific to a particular CPU architecture.
Key term
Examiner insight
Common pitfall
Fun fact
Worked example 14 marks
A programmer writes the high-level instruction `total = 10 + 5`. Describe the low-level steps the CPU might take to execute this.
- 1
Step 1: The instruction `total = 10 + 5` is translated into multiple machine code instructions.
- 2
Step 2: The value 10 is loaded from memory into a special location in the CPU called a register (e.g., Register A).
- 3
Step 3: The value 5 is loaded into another register (e.g., Register B).
- 4
Step 4: The CPU's arithmetic logic unit (ALU) is instructed to perform addition on the values in Register A and Register B.
- 5
Step 5: The result of the addition (15) is stored in a register.
- 6
Step 6: The result (15) is then stored in the memory location that the variable 'total' represents.
Recap
- High-Level Languages (HLLs) are easy for humans to understand and are portable.
- Low-Level Languages (LLLs) are close to machine code and are specific to a CPU.
- One HLL instruction often translates into many LLL instructions.
- HLLs use variable names (e.g., 'score'), while LLLs may use direct memory addresses.
- Computers can only execute machine code (binary).
Quick check
- State one advantage of writing a program in a high-level language.1 mark
- Which type of language, HLL or LLL, is described as 'non-portable'?1 mark