Introduction: Speaking the Language of Computers
Welcome! In this chapter, we are going to explore how we actually talk to computers. Since computers are essentially just a massive collection of tiny switches, they don't understand English or even Python naturally. We need programming languages to bridge the gap between our human ideas and the computer's electrical pulses. Understanding how these languages are classified helps you choose the right tool for the job and understand how software actually runs on hardware.
1. The Big Picture: Levels of Language
Programming languages are generally grouped into two main categories: Low-Level Languages and High-Level Languages. You can think of this as a scale of "closeness." One end is very close to the computer's "brain" (the hardware), and the other is closer to how humans think and speak.
Low-Level Languages
Low-level languages are closely linked to the specific architecture of the computer's processor (CPU). There are two types you need to know:
• Machine Code: This is the most basic level. It consists entirely of binary (1s and 0s). This is the only language a computer actually "understands" and executes directly.
• Assembly Language: This is one step up from machine code. Instead of 1s and 0s, it uses short text commands called mnemonics. For example, instead of a binary string, you might write ADD to add numbers or MOV to move data.
High-Level Languages
High-level languages, like Python, C#, or Java, use English-like words and mathematical notation. They are designed to be easy for humans to read and write. The AQA syllabus specifically focuses on Imperative High-Level Languages. These are languages where you give the computer a series of step-by-step instructions to follow (like a recipe).
Quick Review Box
Low-Level: Close to hardware, uses binary or mnemonics, specific to one type of CPU.
High-Level: Close to humans, uses English-like words, can work on different types of CPUs.
Key Takeaway: Low-level languages are about the machine; high-level languages are about the programmer.
2. Deep Dive: Machine Code vs. Assembly
Don't worry if these seem intimidating! Most modern programmers rarely have to write in these, but knowing how they work is vital for understanding computer systems.
Machine Code (The "Actual" Language)
Every instruction in machine code is a binary pattern. For example, a CPU might see 10110000 01100001 and know exactly which electrical circuits to open or close. Because it is just numbers, it is incredibly difficult for humans to write without making mistakes, and even harder to find bugs in!
Assembly Language (The "Secret Code")
Assembly language was created to make low-level programming easier. It uses mnemonics as a shorthand for machine code.
• Example: Instead of 00000110, a programmer writes LDA (which stands for "Load into Accumulator").
• Crucial Point: Because the CPU still only understands binary, Assembly must be translated into machine code using a program called an Assembler.
Did you know?
Because Assembly is so close to the hardware, it is processor-specific. This means Assembly code written for an Intel processor in a laptop won't work on the ARM processor in your smartphone!
Key Takeaway: Assembly is a human-readable version of machine code, but it still requires an Assembler to turn it into binary so the CPU can run it.
3. High-Level Imperative Languages
The word Imperative comes from the word "command." In an imperative high-level language, the programmer writes a sequence of commands that change the program's "state" (the data stored in memory).
Why do we use them?
Most of the programming you do in class is high-level. It is portable, meaning you can write the code once and run it on many different types of computers. It also allows for abstraction—you don't need to know how the CPU manages its registers; you just need to know how to write total = price + tax.
The Relationship to Low-Level
Computers still can't run high-level code directly. It must be translated into machine code. This is done by either a Compiler or an Interpreter. One single line of high-level code (like a print statement) might turn into dozens or even hundreds of machine code instructions!
Memory Aid: The "H" and "L" Rule
High-level = Human-friendly.
Low-level = Linked to hardware.
Key Takeaway: Imperative languages focus on how a program should achieve a result through a sequence of instructions.
4. Comparing the Levels: Pros and Cons
This is a favorite topic for exam questions! Let's look at why you would choose one over the other.
Advantages of High-Level Languages
• Easier to learn: The code looks more like English.
• Faster development: You can write complex programs much more quickly.
• Portability: The code can run on different types of CPU architectures.
• Easier debugging: It is much simpler to find and fix errors in high-level code.
Advantages of Low-Level Languages
• Speed: Programs can be written to run incredibly fast because they are optimized for a specific CPU.
• Memory Efficiency: They take up very little space in memory (RAM).
• Direct Hardware Control: Essential for writing things like device drivers (software that tells a computer how to talk to a printer or a graphics card).
• No translation needed (for Machine Code): Machine code runs instantly without waiting for a compiler.
Common Mistake to Avoid
Students often think Assembly is "machine code." It’s not! Assembly is text; Machine Code is binary. You need an Assembler to bridge that gap.
Key Takeaway: Use high-level for general apps and speed of writing; use low-level when you need every bit of performance or direct control over hardware.
Final Summary Checklist
Before you move on, make sure you can:
• Define Machine Code as binary and the only language executed by the CPU.
• Explain that Assembly uses mnemonics and needs an Assembler.
• Describe High-Level Languages as English-like and portable.
• Define Imperative as a sequence of instructions that change the program state.
• State at least two advantages of both low-level and high-level languages.