Programming Paradigms — Procedural, Object Oriented, and Functional Programming

These terms come up all the time but are rarely defined or discussed. So we’re going to have a look at these different ways of thinking about and writing code, and where advantages between them lie.

There are different ways and means to program. Some of them come up only occasionally, while some are becoming increasingly prominent. What defines these things, though, is not so much syntax or pattern as it is the way of thinking about things. These are paradigms.

Procedural or Imperative Programming

Programming procedurally is a very explicit, step-by-step way of coding. It is fundamental and low-level, often not taking advantage of any advanced language features.

for (let i = 1, i <= array.length; i++) {
array.forEach(item => console.log(item));
Object oriented stylemysqli::query ( string $query [, int $resultmode = MYSQLI_STORE_RESULT ] ) : mixedProcedural stylemysqli_query ( mysqli $link , string $query [, int $resultmode = MYSQLI_STORE_RESULT ] ) : mixed
$query = "SELECT first_name, last_name FROM users LIMIT 10";OOP Style$mysqli = new mysqli($host, $user, $pass, $db);
$result = $mysqli->query($query);
Procedural Style$link = mysqli_connect($host, $user, $pass, $db);
$result = mysqli_query($link, $query);

OOP — Object Oriented Programming

This is the dominant paradigm of modern development today. JavaScript, C#, PHP, Python, Ruby, and most of all Java, the Objectest of Object Oriented Programming. It pretty much doesn’t matter what language you think of, it’s probably Object Oriented in one way or another, though the models can vary. There are some edge cases, though. Golang may or may not be an OOP language based on some pretty obscure definitions.

class MyClass {
firstName = "Matt";
function makeNoise() { return 'oink oink' }
function myConstructor() {
this.firstName = "Matt";
myConstructor.prototype.makeNoise = function() {
return 'oink oink';
class Publication {
Date lastRented;
Date returned;
Date publishDate;
String publisher;
function rent() { /* whatever this does */ } function getAvailability() { /* whatever this does */}
class Book extends Publication {
String isbn;
Integer pageCount;
class Novel extends Book {
String title;
String author;
String genre;
class NonFiction extends Book {
String deweyDecimal;
String title;
String subTitle;
class Newspaper extends Publication {
String Headline;
$user = User::find(4);
echo $user->first_name; // Steve
$user->first_name = 'Sam';
$query = "SELECT name, abbreviation FROM states WHERE country_code = ?";OOP Style$statement = $mysqli->prepare($query);
$statement->bind_param("s", $country_code);
$result = $statement->get_result();
Procedural Style$statement = mysqli_stmt_init($link);
mysqli_stmt_prepare($statement, $query);
mysqli_stmt_bind_param($statement, "s", $country_code);
$result = mysqli_stmt_get_result($statement);

Functional Programming

FP is probably the biggest buzzword in terms of paradigms. While OOP has the lion’s share of actual work, a lot of newer languages are more functional, and multi-paradigm languages like JS are supporting more functional ideas.

$statement = mysqli_stmt_init($link);
mysqli_stmt_prepare($statement, $query);
mysqli_stmt_bind_param($statement, "s", $country_code);
$result = mysqli_stmt_get_result($statement);
// pure function
function double(int number) {
return number * 2;
//impure functions
function calculateTax(int amount) {
int taxRate = User.stateTaxRate;
return amount * (taxRate / 100);
function updateTaxRate(int amount) {
User.stateTaxRate = amount;
defmodule MyModule do  def create_date_pair(line) do
|> String.replace("\r", "")
|> String.replace("\n", "")
|> String.split(",")
|> List.to_tuple
def write_map_to_file(map, filename) do
list =, fn {k, v} -> "#{k},#{v}" end)
|> Enum.join("\n")
File.write(filename, list)
{:ok, formatted_value} = difference 
|> trunc
|> abs
|> NumberFormat.to_string
def sum(a, b) when is_integer(a) and is_integer(b) do
a + b

def sum(a, b) when is_list(a) and is_list(b) do
a ++ b

Senior Web Developer based in Bangkok, Thailand. Javascript, Web and Blockchain Developer.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store