Unit 12.4A · Term 4 (Revision)

Programming Paradigms Revision

This revision lesson covers programming language generations, the difference between low-level and high-level languages, assembly language, trace tables, and the roles of compilers and interpreters.

Learning Objectives

  • 11.5.1.1 Distinguish between generations of programming languages
  • 11.5.1.2 Classify programming languages into low and high-level
  • 11.5.1.3 Analyze a simple program written in assembly language
  • 11.5.1.4 Use trace tables to verify the correctness of an algorithm
  • 11.5.1.5 Advantages and disadvantages of high-level languages
  • 11.5.1.6 Advantages and disadvantages of low-level languages
  • 11.5.1.7 Advantages and disadvantages of compilers
  • 11.5.1.8 Advantages and disadvantages of interpreters

Lesson Presentation

12.4A-revision-paradigms.pdf · Slides for classroom use

Key Concepts Review

Generations of Programming Languages

Generation Type Example
1GL Machine code (binary) 01101001 01001010
2GL Assembly language (mnemonics) MOV AX, 5 / ADD AX, BX
3GL High-level procedural Python, Java, C++
4GL Domain-specific, closer to human language SQL, MATLAB
5GL Declarative / AI-based Prolog, Mercury

Low-Level vs High-Level

Feature Low-Level (1GL, 2GL) High-Level (3GL+)
Readability Difficult to read/write Easy to read, closer to English
Portability Hardware-specific, not portable Portable across platforms
Execution speed Fast — direct hardware access Slower — needs translation
Memory control Direct control of registers/memory Abstracted, managed automatically
Use case Drivers, embedded systems, OS kernels Apps, websites, general software

Compiler vs Interpreter

Feature Compiler Interpreter
Translation Entire program at once → executable file Line by line, each time program runs
Speed Faster execution (pre-compiled) Slower (translates during runtime)
Error detection All errors at compile time Stops at first error encountered
Output Standalone executable (.exe) No separate file produced
Source code Not needed at runtime Required at runtime
Examples C, C++, Java (to bytecode) Python, JavaScript, PHP

Trace Tables

1 Example: Trace the Following Code

x = 1 y = 3 WHILE x < 10: x = x + y y = y + 1
Step x y x < 10?
Init 1 3 Yes
1 4 4 Yes
2 8 5 Yes
3 13 6 No → Exit

Revision Tasks

Remember

List the 5 generations of programming languages with one example each.

Understand

Explain 2 advantages and 2 disadvantages of using a compiler vs an interpreter.

Apply

Create a trace table for:
a = 5, b = 2, WHILE a > 0: a = a - b, b = b + 1

Analyze

Why would you choose assembly language over Python for programming a microcontroller? Give 3 reasons.

Self-Check Quiz

Q1: What generation is assembly language?

2nd generation (2GL) — it uses mnemonics like MOV, ADD, SUB instead of binary, and requires an assembler to translate to machine code.

Q2: Why is compiled code faster than interpreted code?

The compiler translates the entire program into machine code before execution, creating an optimized executable. An interpreter translates and executes line by line each time the program runs.

Q3: What is the purpose of a trace table?

A trace table tracks the values of variables step by step as an algorithm executes, helping to verify correctness and find logical errors.