What are programming paradigms?
- Programming paradigms are established conventions and practices that dictate how computer programs are structured and developed
- Programming paradigms offer varied methodologies for software construction
- Different paradigms are suited to different tasks, e.g. simple web applications can be achieved with light-weight procedural languages, complex enterprise-level software can only be achieved with a complex object-oriented paradigm
- New paradigms arise, and existing ones adapt in response to changes in computing and software challenges
Overview of programming paradigms
| Paradigm | Description | Examples of Languages | Key Concepts |
|---|---|---|---|
| Procedural | A subtype of imperative, structured around procedure calls. | C, Go, Rust | Procedures, function calls, structured programming |
| Object-Oriented | Organises code around “objects” (which combine data and functionality) rather than functions. | Java, C#, Swift | Classes, inheritance, polymorphism, encapsulation |
| Assembly | Low-level mnemonic representation of machine code for a specific computer architecture. | x86-64 Assembly, ARMv8 Assembly | Registers, mnemonics, memory addresses, opcodes |
Strengths & weaknesses of programming paradigms
| Paradigm | Strengths | Weaknesses |
|---|---|---|
| Procedural | - Efficient execution of straightforward tasks - A clear flow of control (top to bottom) - Ease of implementation for algorithms - Strong emphasis on step-by-step procedure execution | - Can become unwieldy for large programs - Lack of modularity can lead to code redundancy - Not ideal for applications with complex states or behaviours - Difficulty in managing and scaling the system as it grows |
| Object-Oriented | - Enhances modularity with encapsulation - Enables real-world modelling using objects - Code reuse through inheritance - Polymorphism allows flexibility in interface design | - Can lead to unnecessary complexity - Inefficiency due to overhead (e.g., memory for objects) - Not always intuitive for all types of problems - Misuse can lead to overly complex inheritance hierarchies |
| Assembly | - Direct control over hardware - Optimised performance due to low-level operations - A transparent understanding of how the machine operates - Potential for very efficient code | - Extremely steep learning curve - Hardware-specific, leading to a lack of portability - Tedious and error-prone due to manual memory management. - Difficult to write, debug, and maintain large programs |