# Programming Languages: High-Level vs Low-Level

- **Track:** Cambridge IGCSE™ Computer Science (0478 / 0984) (CAMBRIDGE IGCSE 0478)
- **Module:** Section 4: Software & Translators
- **Estimated Duration:** 15 minutes
- **Access:** Open Theory (All-Access for Interactive IDE &amp; Autotests)

---

## Theory & Conceptual Background

A high-level language uses problem-oriented statements and familiar words. It is usually easier to write, debug and maintain than low-level code. A compiler or interpreter is needed. Source code can often be moved between computer types when a suitable translator and required libraries exist; portability is not automatic for every program.

Low-level languages are closely tied to a processor's instruction set. Machine code consists of binary instructions executed directly by the CPU. Hexadecimal can be used as a shorter human representation of those bits. Assembly uses mnemonics such as ADD and requires an assembler to produce machine code. In the syllabus model, an assembly instruction corresponds to a machine instruction.

## Choosing a language

A school booking system benefits from high-level features for text, data handling and maintainable logic. Writing every operation as register instructions would increase development effort.

A small embedded controller may benefit from low-level control over hardware and memory. A programmer can optimise critical operations, but assembly is not guaranteed to outperform a compiler or meet a time deadline. The whole hardware/software design determines performance. Assembly for one instruction set generally needs changes to run on another.

## Compare independently

Choose a suitable language level for a portable stock-management application and for a small processor-specific control routine. For each, explain two relevant benefits and one cost. Use readability, portability, hardware control, memory use and development effort rather than claiming a language is always best.

---

## Interactive Exercises & Autotest Specifications

### Exercise 1: Exam-Style Check: High-Level vs Low-Level Languages (Multiple choice, 25 XP)

**Instructions:**
Which of the following statements correctly characterizes High-Level Languages (HLL) compared to Low-Level Languages (LLL)?

**Options:**
- **A**: High-level languages use English-like statements, are portable across different hardware platforms, but must be translated before execution.
- **B**: High-level languages are hardware-dependent and cannot run on different CPU architectures.
- **C**: Low-level languages require no understanding of internal CPU registers or hardware architecture.
- **D**: High-level languages execute directly on CPU silicon without any translator.


**Autotest Expectations:**
- **Correct option selected**: `selection_match` -> Expected: `b`

### Exercise 2: Exam-Style Question: Classify Programming Language Suitability (Fill in blank, 35 XP)

**Instructions:**
Classify each development requirement by the most appropriate language category ('High-Level Language', 'Assembly Language', or 'Machine Code'):

1. Directly manipulating CPU hardware registers and I/O ports in a real-time sensor device: [blank_1]
2. Rapidly building a cross-platform database application with portable, readable code: [blank_2]
3. The raw binary instructions executed directly by CPU logic circuits without translation: [blank_3]


**Starter Code:**
```text
{"prompt":"Classify each scenario as \"High-Level Language\", \"Assembly Language\", or \"Machine Code\":","template":"1. Direct register manipulation: [blank_1]\n2. Cross-platform database application: [blank_2]\n3. Raw binary executed by CPU: [blank_3]","word_bank":["Assembly Language","High-Level Language","Machine Code","Compiler","Pseudocode"],"blanks":[{"id":"blank_1"},{"id":"blank_2"},{"id":"blank_3"}]}
```

**Autotest Expectations:**
- **Register manipulation uses Assembly Language**: `text_exact` -> Expected: `Assembly Language`
- **Cross-platform app uses High-Level Language**: `text_exact` -> Expected: `High-Level Language`
- **Direct execution uses Machine Code**: `text_exact` -> Expected: `Machine Code`

### Exercise 3: Application: Check the reasoning (Fill in blank, 30 XP)

**Instructions:**
Work out each answer before submitting. Language closest to machine instructions: assembly or Python? Does assembly alone guarantee a timing deadline: yes or no? High-level source is generally more portable or less portable across processors?


**Starter Code:**
```text
{"prompt":"Application: Check the reasoning","template":"1. Language closest to machine instructions: assembly or Python? [blank_1]\n2. Does assembly alone guarantee a timing deadline: yes or no? [blank_2]\n3. High-level source is generally more portable or less portable across processors? [blank_3]","blanks":[{"id":"blank_1"},{"id":"blank_2"},{"id":"blank_3"}],"word_bank":["assembly","Python","yes","no","more portable","less portable"]}
```


