Programming Paradigms
What a paradigm is
A programming paradigm is a style or approach to writing programs. The same problem can often be solved in different paradigms. A-Level covers imperative (procedural), object-oriented, and declarative (including functional) paradigms.
Imperative / procedural
Programs are written as a sequence of commands that change the program's state, organised into procedures/functions.
- Focus: how to do something, step by step.
- Uses variables, assignment, sequence, selection, iteration and subroutines.
- Languages: C, Python (procedural style), Pascal.
- Good for: straightforward, well-defined tasks.
Object-oriented
Programs are built from objects (data + methods), using encapsulation, inheritance and polymorphism (see the OOP note).
- Focus: modelling real-world entities and their interactions.
- Good for: large, complex systems; reusable, maintainable code.
Declarative
The programmer states what result is wanted, not the step-by-step how. Two common kinds:
- Functional programming — programs are built from functions that take inputs and return outputs, avoiding changing state (no side effects). Functions can be passed around like data (first-class functions), composed together, and use recursion rather than loops. Examples: Haskell, Lisp; SQL is partly declarative. Benefits: predictable, easier to test/parallelise.
- Logic programming — you declare facts and rules, and the language works out answers (e.g. Prolog).
Comparison
| Paradigm | Focus | Key idea | Example use |
|---|---|---|---|
| Procedural | How (steps) | Sequence of commands + subroutines | Small utilities, scripts |
| Object-oriented | Objects | Encapsulation, inheritance, polymorphism | Large applications |
| Functional | What (results) | Pure functions, no side effects | Data transformation, concurrency |
| Logic | Facts & rules | Declare knowledge, query it | AI, expert systems |
Choosing a paradigm
There is no single "best" — the choice depends on the problem, the team, and the tools. Many modern languages are multi-paradigm (e.g. Python supports procedural, OOP and functional styles).
Worked example
A program must transform a large dataset with no shared state, ideally running in parallel. Which paradigm suits it?
- Functional — pure functions with no side effects are predictable and easy to run in parallel, making them ideal for data transformation. ✓
Common mistakes
- Treating paradigms as languages — a language can support several paradigms.
- Confusing imperative (how) with declarative (what).
- Forgetting functional programming avoids side effects / changing state.
Exam tips
- Give a one-line definition and an example use for each paradigm.
- Contrast imperative (how) vs declarative (what).
- Know the functional-programming keywords: pure functions, no side effects, first-class functions, recursion.
Key facts to remember
- Procedural/imperative = ordered commands (how); OOP = objects with encapsulation/inheritance/polymorphism.
- Declarative = state the desired result (what): functional (pure functions, no side effects, first-class functions) and logic (facts + rules).
- Choice depends on the problem; many languages are multi-paradigm.