Programming Paradigms Overview
Programming Paradigms
A programming paradigm is a fundamental style or way of programming. It provides the view of the execution of the system in terms of functions and methods.
1. Imperative Programming
Focuses on describing how a program operates through a sequence of statements that change the program state.
- Procedural Programming: Based on the concept of procedure calls (e.g., C, Pascal).
- Object-Oriented Programming (OOP): Based on the concept of “objects” which contain data and code (e.g., Java, C++, Python).
2. Declarative Programming
Focuses on describing what the program should accomplish without explicitly listing the control flow.
- Functional Programming: Treats computation as the evaluation of mathematical functions and avoids changing-state and mutable data (e.g., Haskell, Lisp, Scala).
- Logic Programming: Based on formal logic (e.g., Prolog).
- Reactive Programming: Focused on data streams and the propagation of change (e.g., RxJS, Combine).
Key Differences
| Paradigm | Focus | State Management |
|---|---|---|
| Imperative | How to do it | Explicitly managed |
| Declarative | What to do | Immutability preferred |
Summary
Most modern languages are multi-paradigm, allowing developers to choose the best approach for specific tasks.
Programming Paradigms
Programming paradigms are fundamental styles of computer programming. They are generally categorized into two main branches:
1. Imperative Programming
Focuses on describing how a program operates through statements that change the program state.
- Procedural: Organizes code into procedures or subroutines.
- Object-Oriented: Organizes code into objects that contain both data and methods.
2. Declarative Programming
Focuses on describing what the program should accomplish without explicitly listing the control flow.
- Functional: Treats computation as the evaluation of mathematical functions and avoids changing-state and mutable data.
- Logic: Based on formal logic, where programs are expressed as a set of facts and rules.
- Mathematical: Focuses on formal mathematical expressions and proofs.
- Reactive: Focuses on data streams and the propagation of change.