Programming Paradigm
The programming paradigm is all about the writing style and organizing the program code in a specific way. Each paradigm advocates a specific way to organize the program code.
A programming language is essentially a problem solving tool. For each problem there can be many solutions. Further, each solution can adopt a different approach in providing solution to the problem.
The computer programs are written using different programming languages. Each programming language has unique programming style that implements a specific programming paradigm.
For example , the C language follows procedural programming paradigm . Whereas the C++ , python and java are said to be object oriented programming ( OOP ) paradigm.
The computer programs essentially designed and developed to provide a solution to a specific problem . Different programming approaches have evolved over a period last few decades.
Each programming paradigm advocates a set of principles and rules that the programming language must implement. The programming paradigm is enforced by the programming language compiler during the program compilation stage.
It is important for the students of computer science to be familiar with the concept of programming paradigm , different types and the respective languages.
In this tutorial , you will learn what is programming paradigm , different paradigm types and their features and its suitability for different software applications.
Let us start with a simple introduction to the concept of paradigm.
Programming Paradigm
Table Of Contents
What Is Programming Paradigm ?
The word paradigm derives from Greek and Latin. It simply means pattern , model programming paradigm or a set of rules that defines a standard.
However , in the context of programming languages , the term paradigm means set of design principles that defines the program structure.
The programming paradigm is all about how me model and organize the program code. For example . the OOP paradigm represents everything in the form of objects. Whereas , the function programming represents the program as set of functions.
A computer software is developed keeping in mind a specific problem and provides solution to that specific problem.
For example , Microsoft Office word has been developed to provide solution to the user for creating different types of documents. Similarly , there are software for airline ticket reservation , stock market analysis , hospital management and so on.
However , a problem can be solved in many different ways or approaches. A programmer can evaluate different approaches in order to select the best option.
And therefore , a computer program can be developed using different programming languages that belong to different paradigms. Each approach to the solution will have some merits and demerits.
In other words , the programming paradigm is all about different approaches used to find a software solution to the problem. Each solution to the problem has its own advantages and disadvantages.
Some programming languages that clearly belong to a specific paradigm . However , there are programming languages that do not fall under a one specific paradigm. Such languages might allow the program code that implements more than one paradigm.
Such programming languages are referred to as multi-paradigm programming languages.
Definition Of Programming Paradigm
The programming paradigm is defined as a set of principles , ideas , design concepts and norms that defines the manner in which the program code is written and organized.
The programming paradigm does not specify the programming language syntax . The paradigm simply defines the program structure and the set of principles that the programming language compiler should enforce.
A programming paradigm is a framework that defines how the programmer can conceptualize and model complex problem to be solved.
Types Of Programming Paradigms
The programming paradigms can be classified into two main types. The paradigm type depends upon the programming language features and a particular style of organizing the program code.
- 1. Imperative Paradigm.
- 2. Declarative Paradigm.
Imperative Paradigms
The imperative paradigm is said to be command driven. The program code in imperative paradigm programming language directs the program execution as sequence of statements executed one by one.
The imperative style program consist of set of program statements. Each statement directs the computer to perform specific task.
In imperative style program , the programmer has to elaborate each statement in details . Each statement directs what is to be done and how it is to be done.
The execution of the program statements is decided by the control flow statements. And the program flow can be directed as per the program logic.
The imperative paradigm programming languages include Fortran , Algol , Pascal and Basic.
Declarative Paradigms
The declarative paradigm is a programming paradigm that is focused on the logic of the program and the end result. In this paradigm that control flow is not the important element of the program.
The main focus of the declarative style of programming is achieving the end result .This paradigm is straight forward and to the point while writing the program code.
Difference Between Imperative And Declarative Paradigm
The declarative approach to the programming is pretty much straight forward that leads to what is do be done.
On the contrary , the imperative style of programming consist of number of computational statements that focuses on how it is to be done.
Let us discuss one simple example that would highlight the fundamental difference in the programming approach for imperative and declarative paradigm.
In this example , let us imagine that you have to invite your friend to your house. As per the declarative style , you simply give him your address and let your friend figure out how to reach your home.
As per the second imperative approach , instead of giving him simply address , you would rather write down number of statements. Each statement would guide him step by step to reach your place.
Types Of Imperative Programming
- 1. Structured Programming.
- 2. Procedural Programming.
- 3. Object Oriented Programming.
- 4. Database Query Language.
Types Of Declarative Programming
- 1. Functional Programming.
- 2. Logic Programming.
Structured Programming
The structured programming is derived from imperative paradigm. This paradigm is a improved approach as compared to the imperative paradigm. The structured programming is also alternately referred to as modular programming.
The structured programming intends to optimize the code by using the program control flow constructs , decision making ( If , If Then , Else ) constructs and the iteration constructs ( For , while loops ) , blocks and the functions.
The main intent of the structured programming approach is to improve the readability of the code. This approach also facilitates the re-usability of the code.
Structured Programming
Computer Programming
The structured programming approach does not advocate the use of unconditional control statements such as goto constructs. The use of goto constructs can result into a spaghetti code that is difficult to debug.
In modular ( structured ) programming , the program code is optimized for readability and re-usability by dividing the code into semi independent modules. These modules can be called number of times as may be required.
Types Of Structured Programming
The structured programming approach can be of basically three types .
- 1. Procedural Programming.
- 2. Object Oriented Programming.
- 3. Database Query Language.
Procedural Paradigm
What Is Procedural Programming ?
The program based on procedural paradigm consist of set of procedures. The procedures are also referred as function , method or subroutines.
The program structure in procedural programming consist of set of functions. Each performs a specific operation.
The function consist of group of computational steps that directs the computer to perform specific operation. The function once defined can be called many time in the program to repeat the same operation.
The programmer can either use standard library functions or create library of user defined functions.
The C programming language is the most commonly used and popular language that still used in the software industry.
Read More
Object Oriented Programming
OOP Paradigm
The object oriented programming is a type of structured programming that views the program components as objects. In OOP programming , all the program components are represented as objects.
An object binds the data and associated methods together as single unit. As such the programmer can control the data access permissions by defining the access specifier.
The OOP programming protects the program data from inadvertent operations by another methods. And therefore , the object oriented programming offers robust security features .
The OOP paradigm compliant languages such as C++ , Java and python are extensively used for enterprise level software projects.
Read More
Object Oriented Programming ( OOP )
Database Query Language
The database query language such SQL ( Structured Query Language ) is the most commonly used example of model based language.
The database is vital component of most software projects. Most RDBMS ( Relational Database Management System ) support the SQL for database programming.
The software application communicates with the RDBMS with the help of SQL commends . The RDBMS in turn communicates with the database and executes the SQL commands to perform the desired database operations.
The database query language is also alternately referred to as model based programming.
Read More
Functional Paradigm
What Is Functional Programming ?
The functional programming comes under declarative paradigm. The declarative paradigm focuses on what is to be solved. Whereas the imperative approach focuses on how it to be solved.
As the name suggest , the functional programming is based on the mathematical functions. The functional programming attempts to solve the problem by composing mathematical functions as program components.
In functional programming style the computer program is created with the application and composing the mathematical functions.
In functional programming , the program written in programming language will always produce output exactly similar to its equivalent mathematical function.
For example , let us consider one simple mathematical function.
In this function — f ( x ) = x + 2 for a given value of x , the output will be the same.
If x = 4 then the output will be f ( 4 ) = 4 + 2 = 6.
If x = 5 then the output will be f ( 5 ) = 5 + 2 = 7.
The immutability is one of the most important feature of the functional programming.
For example if you create a variable :
Var a = 100 ; The variable value will remain same for the life span of the variable.
Var b = a + 10 ; Even here the value of a remains the same.
The biggest advantage of the functional programming is that these programs can easily run on the multi-core and multi-threaded environment.
In functional programming , the functions are treated as first class citizens. Let me explain the meaning first class citizen in this context.
This simply means that the function can be passed as an argument in a function call statement. Similarly , the function can also be returned as a value. Just similar to the variable returned during the function call.
Logic Paradigm
What Is Logic Programming ?
The logic programming is a declarative programming paradigm that is based on the logic and the control . The term logic essentially means facts and rules . Whereas the control means an order of rules.
The term Algorithm is defined as logic plus control ( logic + Control ). The logic defines what should be solved whereas the control defines how it should be solved.
The main advantage of the logic programming is that the programmer needs to simply define the what part of the problem. And the system finds the best solution to that problem.
The program written in logic programming language consist of set of program statements in the logical form. Each statement is an expression of facts , rules and the order of rules.
The logic programming is an abstract model of computation. It is based on the first order predicate logic. The predicate logic is also referred to as first order logic.
The clauses are an important element of the logic programming. In other words , a logic program is a set of clauses .
The prolog is an example of declarative paradigm rule based logic programming language. The prolog program consist of set of program statements expressed in terms of facts , rules and the control.
Programming Paradigm FAQ
What Is Programming Paradigm ?
The programming paradigm is all about different approaches used in the programming languages to organize the program code.
The programming paradigm also means different styles of writing the program code. It also means different approaches to solve a specific problem.
What Is the difference between programming language and paradigm ?
The computer program is essential part of the computer architecture. The program code consists of set of instructions that directs the computer to perform various operations.
The computer programs are written using human readable high level programming languages such as C, C++ , Java, Python and others.
The high level programs are compiled to low level machine readable programs that computer can directly execute.
The programming language and programming paradigms are two different things. The programming paradigm advocates a particular style and organizing the program code.
For example , the java is a programming language that is based on the object oriented style of organizing the program code. Similarly, other programming languages can be based on different programming paradigms.
What is the definition of programming paradigm ?
In computer architecture , the programming paradigm is defined as a set of principles , ideas , design concepts and norms that defines the manner in which a program code is written and organized.
The programming paradigm does not specify the programming language syntax . The programming paradigm simply defines the program structure.
The programming paradigm also defines the set of principles that the programming language compiler should enforce during the program compilation.
A programming paradigm is a framework that defines how the programmer can conceptualize and model complex problem to be solved.
Which are the programming paradigms ?
Some of the most commonly used major programming paradigms include :
- Imperative Paradigm.
- Declarative Paradigm.
- Structured Paradigm.
- Procedural Paradigm.
- Object Oriented Paradigm.
- Database Programming.
- Logical Paradigm.
- Functional Paradigm.
Join The Best Seller
Computer Science Online Course
This is the most comprehensive and unique Computer Science And Programming Fundamentals course Online which will give you in depth understanding of most important fundamental concepts in computer science And Programming .