Programming Paradigms

There are multiple programming paradigms:

Functional Programming

Functional programming is a computer science paradigm that revolves around building programs through the application and composition of functions.

It emphasizes a declarative approach, where function definitions form expression trees that transform input values into output values, as opposed to a series of imperative statements that alter the program's state.

Modular Programming

Separating the functionality of a program into independent, interchangeable modules, such that each contains everything necessary to execute only one aspect of the desired functionality.

Object Oriented Programming (OOP)

Concept of "objects" (sometimes objects of the real world like Person, Employee, Car, Truck) , which can contain data, , in the form of fields (often known as attributes or properties), and code, in the form of procedures (often known as methods).

Classes contain data and procedures.
Objects are instances of classes.

OOP idea inherently encompasses modular programming.

Features :

Structured Programming

Write with structures like statements (if-else), loops, blocks, subroutines.

Parallel Programming

Asynchrony is occurrence of events independent of the main program flow and synchrony is the opposite.
Use asynchrony with multithreading or multiprocessing.

Classifications of parallel programming models can be divided broadly into two areas: process interaction and problem decomposition.

Process Interaction

Process interaction relates to the mechanisms by which parallel processes are able to communicate with each other.

Shared memory is an efficient means of passing data between processes.
In a shared-memory model, parallel processes share a global address space that they read and write to asynchronously.
Asynchronous concurrent access can lead to race conditions, and mechanisms such as locks, semaphores and monitors can be used to avoid these (for example, 2 processes writing to file at the same time cause bug, so write to file using lock. Another example is print to screen with lock).

In a message passing model, parallel processes exchange data through passing messages to one another.
These communications can be asynchronous, where a message can be sent before the receiver is ready, or synchronous, where the receiver must be ready.

Implicit Interaction - In an implicit model, no process interaction is visible to the programmer and instead the compiler and/or runtime is responsible for performing it.

Problem Decomposition

Problem decomposition relates to the way in which the constituent processes are formulated.

Task Parallelism - A task-parallel model focuses on processes, or threads of execution. These processes will often be behaviourally distinct, which emphasises the need for communication.

Data Parallelism - A data-parallel model focuses on performing operations on a data set, typically a regularly structured array.
A set of tasks will operate on this data, but independently on disjoint partitions.

Implicit Parallelism - As with implicit process interaction, an implicit model of parallelism reveals nothing to the programmer as the compiler, the runtime or the hardware is responsible.

Up Next

Next, we delve into essential programming principles that guide developers in writing clean, maintainable, and efficient code. From the famous KISS (Keep It Simple, Stupid) and DRY (Don't Repeat Yourself) principles to YAGNI and more, you'll discover key principles that promote good coding practices.