Download Prospectus


What is a programming paradigm and what types are there?

Programming paradigms are different ways or styles in which a programming language can be organised.  Each paradigm consists of certain structures, features, and ways to tackle common programming problems.  Some paradigms are more suited to certain types of problems, so you would use different paradigms for different kinds of projects.

Programming paradigms are not languages or tools – you can’t ‘build’ anything with a paradigm.  They are more like guidelines, and programming languages aren’t always tied to a specific paradigm.  There are some languages that have been built with a certain paradigm in mind and have features that facilitate that type of programming, however there are also multi paradigm languages that can fit several paradigms.

There are several types of programming paradigms, and they fall into either a declarative or imperative classification.

, What is a programming paradigm and what types are there?

Imperative Programming Paradigm

The word ‘imperative’ comes from the Latin “impero” which means I command.  It’s the same word we get emperor from and is quite apt in this case.  You are like the emperor giving the computer orders which it completes one at a time and then reports back.

The paradigm consists of several statements, and after the execution of all of them the result is stored.  It’s about writing a list of instructions to tell the computer what to do step by step.

In an imperative programming paradigm, the order of the steps is crucial – a given step will have different consequences depending on the current values of variables when the step is executed.

Let’s check out an example in C – a common imperative programming language:

#include <stdio.h>

int main()

{

            int sum = 0;

            sum += 1;

sum += 2;

sum += 3;

sum += 4;

sum += 5;

sum += 6;

sum += 7;

sum += 8;

sum += 9;

sum += 10;

            printf (“The sum is: %d\n”, sum);

            return 0;

}

In this example, we command the computer what to do line by line, then store the value and print it.  If we ran this code the sum printed out would be 55

Within this paradigm we have three ‘sub’ paradigms:

  • Procedural – this allows us to split the instructions we give a computer into procedures.  The primary purpose of a procedure is to accomplish a certain task and cause a desired effect.  An example would be the ‘for loop’.
  • Object-oriented – this is the most popular programming paradigm because of its unique advantages such as the ability to directly associate real-world business problems in terms of code.
  • Parallel processing – this approach is the processing of program instructions by dividing them among multiple processors.  A parallel processing system allows many processors to run a program in less time by dividing them up.  Languages that support this approach are:
    • NESL
    • C
    • C++

Declarative Programming Paradigm

Declarative programming is a programming paradigm where the developer defines what needs to be accomplished by the program, without defining how it needs to be implemented.  In other words – it focuses on what needs to be achieved instead of instructing how to achieve it.

Therefore, the main differences are that imperative tells you how to do something, and declarative tells you what to do.   Some of the sub paradigms within the declarative paradigm are:

  • Logic programming – this paradigm is based on formal logic and takes a declarative approach to problem solving.  This paradigm isn’t made up of instructions, but of facts and clauses.  It uses everything it knows and tries to come up with a world where all of those facts and clauses are true.
  • Functional programming – this paradigm has been in the limelight for a while now because of JavaScript, a very popular functional programming language.  It has its roots in mathematics and is language independent, and its key principle is the execution of a series of mathematical functions.
  • Database processing – this programming methodology is based on data and its movement.  Program statements are defined by data rather than hard coding a series of steps. 

Event-driven Programming

One last paradigm we’re going to look at that doesn’t fall into either the declarative or imperative classification is event-driven programming.  This is a programming paradigm in which the flow of execution is determined by events – for example a user action like a mouse click or key press, or a message from the OS or another program.  An event-driven application is designed to detect events as they happen and do something based on an event-handling procedure.

The idea is an extension of interrupt-driven programming that was found in early command-line environments.

There is a lot more to programming paradigms, but hopefully you’ve enjoyed this introduction to the basics.  We’ll cover some more on paradigms in future articles. In the meantime, if you’re interested in learning more about programming paradigms you can find a great article here

Interested in our courses?

Interested in computer engineering? Find out more about all the computer engineering courses we have available by clicking here.

Diploma in Computer Engineering

Diploma in Computer Science

Diploma in Artificial Intelligence

Alternatively, you can view all our online engineering courses here.

Recent Posts

Understanding the mechanisms involved in a voltage amplifier

Understanding the mechanisms involved in a voltage amplifier In our previous articles, we discussed analogue signals and their characteristics.  We’re going to dive a little deeper into analogue signals and see how a voltage amplifier works. What is an operational amplifier? Operational amplifiers, or op-amps, are one of the basic building blocks of analogue electrical […]

Characteristics of analogue electronics

Characteristics of analogue electronics In our previous articles, we’ve discussed subjects such as the different types of semiconductors and how they work.  We’re now going to focus on analogue electronics—what it is and its characteristics. What is an analogue signal? An analogue signal is continuous; in other words, it can have an infinite number of […]

The structure and mechanism of a Bipolar transistor

The structure and mechanism of a Bipolar transistor In our previous article, we discussed the operation of metal oxide transistors, and now we’re going to have a look at bipolar transistors.  We’ll look at their mechanism and how they work. What is a bipolar transistor? A bipolar junction transistor is a semiconductor device which can […]