DEV Community

Igor
Igor

Posted on

Programming Paradigms

A programming paradigm is a fundamental style or approach to solving problems.

Different programming paradigms provide different ways of organizing and structuring code, and have different strengths and weaknesses. Some of the most common programming paradigms include:

Imperative

  • Is one of the oldest programming paradigm. It is based on Von Neumann architecture. The programmer instructs the machine how to change its state. They state the order in which operations occur, with constructs that explicitly control that order, and they allow side effects, in which state can be modified at one point in time, within one unit of code, and then later read at a different point in time, inside a different unit of code. The communication between the units of code is not explicit.
    Examples of Imperative programming paradigm:

    C : developed by Dennis Ritchie and Ken Thompson
    Fortran : developed by John Backus for IBM
    Basic : developed by John G Kemeny and Thomas E Kurtz

Enter fullscreen mode Exit fullscreen mode

Procedural [Imperative]

  • Focus in dividing a problem in a sequence of steps or procedures well defined. It emphasizes the reutilization through functions or sub routines and is characterized by it’s linear flux of execution.
Examples of Procedural paradigms:

C
C++
Java
ColdFusion
Pascal
Enter fullscreen mode Exit fullscreen mode

Object-Oriented Programming [Imperative]

  • OOP organizes the code in classes and objects, allowing encapsulation, inheritance and polymorphism. It promotes the modeling of real-world objects and their interactions, improving code modularity and maintainability.
Examples of Object Oriented paradigm:

Simula
Java
C++
Objective C
VB .NET
Python
Ruby
Smalltalk
Enter fullscreen mode Exit fullscreen mode

Concurrent / Parallel

  • Involves dealing with multiple tasks or processes that can be executed simultaneously. Parallel programming goes further, taking advantage of multiple processors or cores to execute tasks concurrently, thus improving performance.

Declarative

  • It focuses on describing what needs to be done rather than how to do it. It abstracts low-level implementation details, resulting in more readable and expressive code. SQL is a typical example.

Functional [Declarative]

  • Functional programming treats computation as the evaluation of mathematical functions. It emphasizes immutability, first-class functions, and higher-order functions, resulting in more concise, predictable, and parallelizable code.

Logic [Declarative]

  • It involves specifying a set of logical rules and facts to derive conclusions or solve problems. It is especially suitable for tasks such as knowledge representation, artificial intelligence, and theorem proving.

Sub Routine = Block of code that runs a specific task and can be called from different parts of the program. It’s a form of structuring and organizing the code, making it modular and reusable.

Top comments (0)