Programming Paradigm

By | October 6, 2021
Programming Paradigm

A programming paradigm is an approach to write code using different methods, which also include the problem-solving mechanism of a structure. When a programming language designed, the developers set a structured method which the programmer needs to follow if he codes in that programming language. A programming paradigm is a concept that is used to set a methodology of writing code in a particular programming language.

The programming Paradigm mostly related to the high-level programming languages, you must be heard of object-oriented programming (OOP) which is the most famous programming paradigm, OOP’s are mostly used to solve the real-world problem.


Types of Programming Paradigm

There are commonly two types of Programming paradigms in use:

  • Imperative Programming
  • Declarative Programming

Imperative Programming

If you have coded in C++, Python, Java or any other high language, that means you have used imperative programming, in these programming you may have noticed that the outcome of the program depends upon the steps, in simple words the problem solve step by steps.

In imperative programming, we use commands which define which would be the next step the compiler or interpreter should execute to run the complete program. Imperative programming is similar to cooking, first do this then do this, which means you cannot directly jump to a process until you finish the previous one.

In imperative programming, the flow of the program control by the commands and statements, and the state of the program get change continuously which affects the global state of the computation. The changing of state helps to achieve the goal and it makes the program more logical.

There are two types of Imperative Programming:

  • Procedural Programming
  • Object-Oriented Programming.

Procedural Programming

It is a type of Programming Paradigm, which is derived from Structured programming, programming which focuses on improving the clarity, quality and development time of the computer program. It is also known as Imperative programming.

It is based on the concept of the procedure call. The procedures are sometimes also referred to as routine subroutines and functions. It also follows the concept of functional programming which helps to fix a block of code and increase its reusability.

In procedural programming the code of the program executes linearly with logical steps, it follows the top to bottom approach, the code is written first considered execute with some conditions. The conditions are decided by the procedure calls. For example, if there are two functions in the program the main function executes first and the code will execute top to bottom.

Object-Oriented Programming

In object-oriented programming, we use class and object to solve the problem. Here objects are the instances of the class and class is the blueprint of the solution. All the class operation performs on the object only, the main focus of object-oriented programming is on data rather than procedure or steps.

Object-Oriented programming comes which many properties such as inheritance, data abstraction, polymorphism, etc, which increase the security of data and the reusability of code. Java, C++, Python are some of the programming languages which support for Object-Oriented programming.

Advantages of Imperative Programming
  • It is easy to implement using code
  • Easy to understand the flow of Program
  • Contain Loops, variable, class, etc.
Disadvantages of Imperative Programming
  • A complex problem can not be solved using Imperative
  • Parallel programming is not possible,

Declarative Programming

It is just the opposite of the imperative programming, here programmer has no control over the steps of the code, these programming only concerned with the output of the program rather than the steps to reach the output.

Here in Declarative programming rather than focusing on the steps to the outcome we focus on the logic and output of the program. There are many languages that follow this type of programming paradigms such as regular expression, SQL etc, these languages focus on the output rather than the steps or linear execution of steps.

There are three types of Declarative Programming:

  • Functional Programming
  • Logic Programming
  • Database Processing.
Functional Programming

The Origin of functional programming is derived from Mathematic, as we use different equations and functions in math, we have adopted the same concept and used in programming languages to solve problems. These days each high-level programming languages support functional programming because it reduces the redundancy of code and increases the concept of reusability of code.

Many times, we confused the Procedural programming with Functional programming, but both are different and the main disparity is, the outcome of the same input. As we know that Functional Programming is completely adopted from Mathematic and like mathematics no matter what if the input is same for a function the output would same too, but in Procedural programming the output of the input depends upon the state of the programming, so here in Procedural programming the output of the same input may differ from state to state.

Logic Programming

Logic Programming is completely based on mathematic logic, where we need to follow some set of rules to get a result. Every programming language that supports Logic programming, has some facts and rules about some problem domain.

Prolog, GHC, Parlog, Vulcan, Polka, Mercury, Fnil are the example of Logic programming.

Database Driven Programming

This programming main concern is Data and its organization. Database driven programming mostly focuses on the creation, updating, deletion, and reading of data. These programmings are built on imperative programming methodology but they follow declarative programming. SQL is the example of Database driven programming.

People are also reading:

Leave a Reply

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