Intro

At the end of the day, code is just a collection of human-readable instructions for a computer to compile and execute.

However, it’s not all written the same, because it’s not used the same. The many different use cases and problems various programs address require structuring, styling, and writing code in different ways. The many ways code be structured are called Programming Paradigms. There are many, many paradigms, some distinct and some are rather similar.

Paradigms Aren’t Real

Something beginners and new programmers get wrong is thinking a paradigm is a tool or set of syntax, this is quickly dispelled if they’re paying attention. In truth, paradigms are a collection of guidelines and rules, that influence (sometimes determine entirely) how the program runs and behaves.

Paradigms and Languages

Sometimes the programming language will determine the paradigm to work in, but many popular high-level programming languages are multi-paradigm. Either supporting different ones or having a mixture of features and syntax that borrows from different paradigms.

For Example, Python, Rustm, and JavaScript are multi-paradigm scripting languages. Whereas Haskell, OCaml, and Elixir are Functional languages.

It’s also worth noting that the borders between these different paradigms aren’t clear-cut and well defined. Blurry lines separate them, so much so in fact that I wonder if Venn diagram’s are a better way to visualize them.

Imperative

This is the most common and popular paradigm by far, it’s the one most, of not everyone, codes in. Even those entirely oblivious to the concept of paradigms. In ImperativeProgramming the code directly controls the flow of logic and execution, and explicitly manipulates state.

Procedural

In Procedural Programming the code is structured as procedures that are called in a specific sequence.

Object-Oriented

Object Oriented Programming (OOP) is a very popular paradigm for its ability to represent objects with state and methods. This lends it to many different uses, especially ones representing real-world objects. E.g. GameDev.

Declarative

Declarative Programming hides the the complexity away, making the code as readable to people as possible.

Functional

In this Functional Programming, functions are first-class citizens, so they can be treated like values, assigned to variables, returned and passed around.

Concurrent

Programming that involves completing tasks concurrently, involving multi-threading, process-messaging, and resource sharing. Think of the workflows done by things like Erlang, Elixir, Go routines…etc.

Metaprogramming

This is a very interesting paradigm in which you write programs that will compile and manipulate other programs at their runtime. Usually done by writing themselves as the data inputs for other programs. I did a little bit of this in COMP4959’s fifth lecture.


References