The four different programming paradigms

The four different programming paradigms

According to the Merriam-Webster’s Collegiate dictionary(n.d), a paradigm is “A philosophical and theoretical framework of a scientific school or discipline within which theories, laws, and generalizations and the experiments performed in support of them are formulated”. In essence, we are in reference to patterns and models. With that said, there are four major types of programming paradigms; namely: Imperative, Functional, Logical and Object-Oriented.

The imperative programming paradigm was one of the earliest and was developed using machine-language. It is also the basis on which all hardware is implemented. This was further confirmed by a published journal by Laird(2009) in which he stated that “In imperative programming, statements are instructions at the native machine-level, and they contain states and variables that point right to the memory.”  Some of its merits include but not limited to: close to the machine – fast execution time, more efficient. Whilst, on the other hand, its weaknesses are order sensitive and the limitation of abstraction. Functional programming is essentially less complex and offers better readability than imperative.

This paradigm is thought of to have been originated from a mathematical discipline. Merits include: compare to imperative it has a higher level of abstraction, is not tied to dependency. Some of the weakness include: less efficiency, troubleshooting variables or it’s sequential activities are better handled in both Object-Oriented or imperatively. Unlike the other major paradigms, the Logical paradigm is vastly different in that it focusses primarily on predicate logic — relation. This is also a vital part of the logic circuit of a computer. Merits of this paradigm include: “problems are solved by the system and Proving the validity of a given program is simple” (the University of Central Florida, n.d). Finally, the Object-Oriented paradigm also known as O-O focusses on objects, it’s representation and the behavior they exhibit; rather than variables of the imperative paradigm. O-O borrows from all the major paradigms.

Imperative Example:

int fact(int n) {
 int f = 1;
 while (n > 1) {
   f = f * n;
   n = n – 1;
 return f;

“Notice the assignment operator, the equals (=) sign. The value location of the variable itself was stored in memory” (Wikibooks, 2016)

Functional Example:

Function FindAvg(int x, int y){ return ((x+y)/2);}
Call to function will return an average without storage of value in memory

Logic Example:

  Brother(X,Y)                         /* X is the brother of Y                                   */
       :-                                  /* if there are two people F and M for which*/
       father(F,X),                       /* F is the father of X                               */
       father(F,Y),                       /* and F is the father of Y                            */
       mother(M,X),                   /* and M is the mother of X                             */
       mother(M,Y),                   /* and M is the mother of Y                             */
       male(X).                            /* and X is male                                  */

“That is X is the brother of Y if they have the same father and mother and X is male.” (University of Birmingham, n.d)

Object-Orient Example:

public class Example{
private String name;
public void setName(String n){name = n;}}Class Example has a method setname and a string n that is assigned to a variable name in memory.

Below is an example of an implementation in which the paradigms functional, imperative and object-oriented paradigms are used.

Example provided by Wade(2015) in Java

* This RobotTester java class is created to run and execute the Robot
* java class, which is designed to direct the robot based on a users input and
* calculate the position of the robot in comparison to a starting coordinate.
* author@Geo,Wade
import java.util.Scanner;

public class  RobotTester
   public static void main(String []args)
       // part 1: open a scanner
       Scanner scan = new Scanner(;

       // part 2: Abstract the Robot class
       Robot rTwoD = new Robot();

       // part 3: prompt the user to enter a direction and move the robot
       boolean finished = true;
       while (!finished)
           System.out.println(“Enter 1 to turn Right, Enter 2 to turn Left, Enter 3 to move, Enter Q to quit “);
           int turn = scan.nextInt();

           if (turn == 1)

           else if (turn == 2)
           else if (turn == 3)
               String facing = rTwoD.getDirection();
               System.out.println(“The Robot is facing: ” + facing);
           else finished = false;


       // part 4: close the scanner



“The above Java program demonstrates, Object Creation, Class Abstraction, Method/Functional Abstraction, Control Structures, Block Structures, Conditional Statements, Iteration and Assignment; which are all characteristics of three paradigms.”(Wade, 2015)


Laird, A., 2009. The four major programming paradigms topic paper# 17. Computer Science, April, 3.

Merriam-Webster’s Collegiate (n.d) paradigm, Available at: (Accessed: April 26, 2016).

University of Birmingham (n.d) What are Programming Paradigms?, Available at: (Accessed: April 26, 2016).

University of Central Florida (n.d) Major Programming Paradigms, Available at: (Accessed: April 26, 2016).

Wade, G. (2015) Which are the most used programming paradigms? Which are good coding examples?, Available at: (Accessed: April 26, 2016).

Wikibooks (2016) Introduction to Programming Languages/Programming Language Paradigms, Available at: (Accessed: April 26, 2016).

Leave a Reply

Your email address will not be published. Required fields are marked *

Groope Multimedia © 2019, All rights reserved