I | What are Programming Paradigms?

Tuan Burah
Jan 10 · 6 min read

Overview of the concepts of programming paradigms for beginners..

A theory most students in the field of Information Technology do not fully comprehend is the concepts of “Programming”. Programming is todays leading syllable in edge of every professional body from medicine, engineering, human resource, visual arts, music etc. but,

What is a Programming Paradigm?

It is a collection of distinct set of programming concepts or thought patterns in the field of software programming or development.

Didn’t get it? I know, cuz I didn’t either, at least that’s what Google says.

Now put this in mind, a programming paradigm is just a style of programming or conceptual idea, you use when you write a program under various criteria. There are lots of programming languages that are well-known but all of them need to follow some strategy. So, with that in mind let’s get to the real question,

What are the Programming Paradigms?

There are 04 types of paradigms categorized into 02 sections

Imperative Paradigm

This is the first paradigm you will have to learn before going on to the rest as this will cover the basic knowledge on conceptual programming.

In imperative paradigms, you will write computer programs by telling the computer how to solve the program, providing the method, as well as telling it what to solve, providing the data. The Imperative Paradigm has two types of sub-paradigms namely:

The what? As the name states, it is a procedural method where, you will write methods that would run operations based on the data you provide.

The when? Most programs written in POP are single-file applications, meaning you practically can’t build large applications in this paradigm.

Example: Calculate the sum of first 100 numbers in Python.

>> SUM of first 100 numbers is: 5050

The what? In OOP, you will write both the methods and the data inside classes and objects. Those are the two main aspects used when writing OO code followed by the 04 major principles, Encapsulation, Inheritance, Abstraction and Polymorphism. This has several advantages over procedural programming:

  • OOP is faster and easier to execute
  • OOP provides a clear structure for the programs
  • OOP avoids repeatable codes which makes the code easier to maintain, modify and debug
  • OOP makes it possible to create full reusable applications with less code and shorter development time

So, what’s the big deal in using the complex OOP paradigm when we could use a procedural paradigm?

The when? Believe me, nobody would stop you from writing your programs in one extremely long file with hundreds of functions and thousands of lines of code, that would consume your invaluable time testing and debugging.
If you, for once without being stubborn, follow the principles of object-oriented programming you will be able to produce reusable, maintainable, scalable clean code which would be very easy in the case of testing and debugging.

Example: using Java

>> Welcome
>> Max speed is 320

Declarative Paradigm

This paradigm will take you to another level so get ready to collapse your fully functional innocent minds.
Let’s go over the prerequisites first,

  • Of course you need to have some knowledge of imperative programming paradigms (C, C++, Python, Java, CSS) any of these will do.
  • You should know some basic theory of programming languages so you should know what types are there and how they work, how evaluate of expressions wok and what are the difference between a compiler and interpreters.

In declarative programming, you only tell the computer what to do providing the data, while in imperative programming you tell the how and what both. This paradigm is designed to build complex program algorithms with human readable code that is easy to understand compared to imperative languages.

Declarative programming is, currently, the dominant paradigm of an extensive and diverse set of domains such as databases, templating and configuration management.

The what? The concept of functional programming has been around for a long time, but it is currently enjoying a comeback. It is mostly used to get rid of the issues which come up with concurrency.

In-depth Analysis. The functions used here are not similar to the functions in contrast to the imperative paradigm, where their values are based on arguments, order of evaluation and can also have side effects (change of state). Functional programming languages always uses pure functions by avoiding shared state, mutable data, and side-effects.

Functional Programming

A pure function will have no side-effects meaning, for the same input it will always provide the same output. A program in a functional programming language is a pure-function itself.

A functional program in general are easier to verify and that is a huge part of functional programming since we can mathematically prove the correctness of our algorithms.

The when? In my opinion, they are suitable in two main things: Game AIs and mathematical computations. Game AIs is because of its nice list manipulations while mathematical computations is because of its syntax.

Example: calculate the sum of an array of a list of numbers

The what? As the name states, this programming paradigm relies on the logical behavioral concepts of data by controlling how facts and rules are expressed rather than only mathematical functions. The previous programming paradigms used a structured control flow on how to evaluate function calls on one another and depict when to execute, but the logic paradigm uses its predicated logic clauses also known as logic rules .

Logic Programming Work Flow

The when? In my opinion, the most used logic programming language is “Prolog”, which has been around for 50 years. Prolog is widely used in,

  • NLP (Neuro-Linguistic Programming) particularly in syntax and computational semantics
  • Expert Systems
  • Artificial Intelligence
  • Machine Learning
  • Deductive databases
  • Symbolic computation; i.e. calculus
  • Parsing, etc.

I will not explain any of the above uses due to its complexity since this blog is for beginners, but you’ll need to understand a practical scenario so follow the simple example I made below. You can do it yourself in SWI-Prolog if your a programming enthusiast.

Prolog IDLE Output?- studies(John, X).
?- teaches(Mary, X).
?- professor(Mary, John).

The facts are known as knowledge banks.
The rules creates relationships between the facts meaning, when we run a query, the prolog will read the facts along with the rules to throw an output. It’s like they talk with each other.

So in contrast, rules and facts used in the logic paradigm are similar to methods & data used in the imperative paradigm except that the two are read and computed under different conceptual patterns also known as “Paradigms”.

Therefore I will conclude this blog grasping the theory of programming paradigms and I hope you have stayed with me till the end of this article. To know more about each programming paradigm, visit my publication in Programming Paradigms. Apologies, if you read this blog before I published the other articles.

Programming Paradigms

A map for beginners to explore the vast universe of programming.

Programming Paradigms

Programming Paradigms publishes the basic knowledge of programming for beginners readable at any age. Subscribe to receive updates right in your inbox.

Tuan Burah

Written by

Student Member of British Computer Society — Royal Charter MBCS

Programming Paradigms

Programming Paradigms publishes the basic knowledge of programming for beginners readable at any age. Subscribe to receive updates right in your inbox.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

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