Programming Paradigms

Programming paradigms attempt to classify programming languages according to their features and capabilities. In this article, you will learn what are the programming paradigms available for python language. The python programming language supports following programming paradigms.

  1. Imperative programming paradigm
  2. Structural Programming Paradigm
    1. Procedural Programming
    2. Functional Programming
  3. Object-Oriented Programming Paradigm
  4. Event-Driven Programming paradigm

Imperative Programming Paradigm

The word “imperative” means urgent or give command. In this programming paradigm the commands are executed in step-by-step manner. It just change the state within the program. Therefore, cannot run complex codes in imperative programming. The languages like C, FORTRAN, BASIC, PL/I supports this paradigm.

Advertisements

Example:

x = 10
y = 20
x + y
30
//each of the above code is executed line by line

Structured Programming Paradigm

We can use structured programming when the programming language supports it. In this paradigm, the program is written clearly by dividing the program into blocks, procedures, functions, using if-else and loop constructs. That is the reason, structured programming is divided into – procedural programming paradigm and function programming paradigm.

Procedural Programming Paradigm

The procedural programming paradigm is supported by those languages that can call procedures. A procedure is a routine, subroutine, or function that execute commands in step-by-step manner.

A procedural programming is also imperative in nature and change the state of the program itself. Imperative programming give commands to computer describing “how” a program operates. It uses algorithms which is step-by-step method of solving problems.

Functional Programming Paradigm

The functional programming uses procedures called functions and the program is structured using many functions whose nature is similar to a mathematical function.

It takes the declarative approach and does not change the state of the program. Output of the functional programming is dependent on the arguments it takes. Similar to a mathematical function, from one set to another set. The declarative nature of functional programming focus more on “what to do” than “how to do” approach of imperative programming paradigm.

Advertisements

Remember that a subroutine is not a mathematical function. Therefore, functional programming is popular in academics. Java, C, FORTRAN, BASIC are few examples of structural languages.

Object-Oriented Programming Paradigm

The object-oriented approach translates the real world object into abstract objects with properties and methods. The object is created out of a template called class. The properties are the description or attributes of an object and the behavior of the object is modeled by its methods.

For example,

//Here is the JavaScript code to create a class
class Car{
     constructor(name, model){
          this.carName = name;
          this.carModel = model;
          }
//method of the class
     start(){
          console.log("The this.carName is started!");
          }
     }
//Now we create an object using Class
const myCar = new Car("Volvo","XCS00");

Event-Driven Programming Paradigm

In the event driven programming paradigm, the control of the program is with the user-events such as mouse-clicks, key-press, etc.It is very popular paradigm in web programming using JavaScript, Python, NodeJS, etc.

In this programming paradigm, the program waits and listens for an event to happen. The moment an event take place, the event handler will respond to the event with appropriate message.

Advertisements

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Exit mobile version