Introduction to Programming Paradigms

advanced25 min

Learning objectives

  • Define a programming paradigm
  • Distinguish between imperative, declarative, procedural, object-oriented and functional programming

Learn

AQA 4.1.2.1 — Programming paradigms

Retrieval: every program written across Year 12 and Sequence 10 — including last lesson's recursive, exception-handling-aware functions — has been written in essentially the same style: a sequence of instructions, organised into named functions. This lesson steps back and asks: what is that style actually called, and what are the genuine alternatives to it?

Key vocabulary

  • Programming paradigm — a fundamental style or approach to structuring and writing programs.
  • Imperative — a paradigm built around how to do something: an explicit sequence of instructions that change the program's state step by step.
  • Declarative — a paradigm built around what result is wanted, leaving the how to the underlying system (SQL's SELECT, which never says how to search the table, is a declarative example you already know from databases).
  • Procedural, object-oriented and functional — three specific paradigms this course covers, all of which happen to be imperative at their core, organised in different ways.

Understand — imperative vs declarative is about how vs what

An imperative instruction says exactly how to get a result: "start with an empty list, loop through these values, and add each one that's over 50 to the list." A declarative instruction just states the result wanted: "the values that are over 50" (an SQL WHERE clause, or a Python list comprehension, both do this) — the mechanism that actually finds them is left entirely to whatever executes the instruction. Procedural, object-oriented and functional programming are all, underneath, imperative — they differ from each other in how they organise the "how," not in whether they specify it.

See it — the same task, two ways

# Imperative - explicitly says HOW
high_scores = []
for score in scores:
    if score > 50:
        high_scores.append(score)
# Declarative-flavoured - states WHAT is wanted, not the step-by-step mechanism
high_scores = [score for score in scores if score > 50]

Both produce the same result. The second doesn't spell out "create an empty list, loop, check, append" — it states the desired outcome and lets Python's own machinery handle the mechanism, which is exactly the declarative idea, even though this specific example is still Python (a fundamentally imperative-rooted language borrowing a declarative-flavoured construct).

Identify it — classify these paradigms

For each, identify which paradigm it most directly illustrates (procedural, object-oriented, or functional) and justify your answer in one sentence:

  1. A program built from a sequence of def functions, each one taking data as parameters and returning a result, with no classes anywhere.
  2. A program where a BankAccount object holds its own balance and provides a withdraw() method that only it can use to change that balance.
  3. A program that transforms a list entirely through map() and filter() calls, never reassigning an existing variable's value.

(1: procedural - functions operating on data passed to them, no bundling of data and behaviour. 2: object-oriented - data (balance) and the behaviour that changes it (withdraw) are bundled together inside one object. 3: functional - built from transforming functions rather than step-by-step mutation, matching Sequence 10's own recursion-and-immutability preview.)

Common mistake

Treating "procedural" and "imperative" as synonyms. Procedural programming is one specific way of organising imperative code (into named procedures/functions); object-oriented programming is also imperative underneath, just organised around objects instead. "Imperative" is the broader category; "procedural" is one specific style within it.

Check your understanding

A student says: "Object-oriented programming isn't imperative, because it uses classes instead of loops and assignment." Explain what's wrong with this statement. (OOP still uses loops, assignment and step-by-step instructions throughout its methods - it's still imperative underneath. What's different about OOP isn't that it avoids imperative mechanics, but how it organises data and behaviour together into objects, which is a separate, orthogonal question to imperative-vs-declarative.)

Challenge

Find (or write) a short piece of Python code that combines features of at least two different paradigms in one program (for example, a function that uses a list comprehension internally). Identify which paradigm each part illustrates.

Looking ahead: the next lesson takes procedural programming — the paradigm every program in this course has used so far — and evaluates it properly: what is it actually good at, and where does it start to strain?

Test yourself

Check your understanding with exam-style questions.

Go to Exam Practice
Log in to track this lesson on your progress dashboard.
Log in