The Wayback Machine - https://web.archive.org/web/20240623072149/https://www.geeksforgeeks.org/difference-between-imperative-and-declarative-programming//
Open In App

Difference Between Imperative and Declarative Programming

Last Updated : 22 Mar, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

A programming paradigm is an approach to solve problems using some programming language or also we can say it is a method to solve a problem using tools and techniques that are available to us following some approach. There are lots of programming languages that are known but all of them need to follow some strategy when they are implemented and this methodology/strategy is paradigms. Apart from varieties of programming languages, there are lots of paradigms to fulfill each and every demand.

Programming Paradigms

Programming Paradigms

Imperative Programming as the name suggests is a type of programming paradigm that describes how the program executes. Developers are more concerned with how to get an answer step by step. It comprises the sequence of command imperatives. In this, the order of execution is very important and uses both mutable and immutable data. Fortran, Java, C, C++ programming languages are examples of imperative programming. 

Declarative Programming as the name suggests is a type of programming paradigm that describes what programs to be executed. Developers are more concerned with the answer that is received. It declares what kind of results we want and leave programming language aside focusing on simply figuring out how to produce them. In simple words, it mainly focuses on end result. It expresses the logic of computation. Miranda, Erlang, Haskell, Prolog are a few popular examples of declarative programming.

After getting the basics of understanding of both the languages now let us do discuss the key differences between these two different types of programming

Imperative Programming

Declarative Programming  

In this, programs specify how it is to be done.   In this, programs specify what is to be done.  
It simply describes the control flow of computation.  It simply expresses the logic of computation.  
Its main goal is to describe how to get it or accomplish it.   Its main goal is to describe the desired result without direct dictation on how to get it.  
Its advantages include ease to learn and read, the notional model is simple to understand, etc.   Its advantages include effective code, which can be applied by using ways, easy extension, high level of abstraction, etc.  
Its type includes procedural programming, object-oriented programming, parallel processing approach.   Its type includes logic programming and functional programming.  
In this, the user is allowed to make decisions and commands to the compiler.   In this, a compiler is allowed to make decisions.  
It has many side effects and includes mutable variables as compared to declarative programming.   It has no side effects and does not include any mutable variables as compared to imperative programming.  
It gives full control to developers that are very important in low-level programming.   It may automate repetitive flow along with simplifying code structure. 
In imperative programming, the programmer is responsible for optimizing the code for performance In declarative programming, the system optimizes the code based on the rules and constraints specified by the programmer.
In imperative programming, variables can be mutable. In declarative programming, variables are typically immutable.

Similar Reads

Difference between Functional and Imperative Programming
Functional Programming: Functional Programming, as the name suggests, is a type of programming paradigm that is being created explicitly simply to support a purely functional approach to solving problems. This type of programming is mainly used when solutions are easily expressed in function and have very little physical meaning. It simply helps us
3 min read
Difference between Procedural and Declarative Knowledge
Procedural Knowledge: Procedural Knowledge also known as Interpretive knowledge, is the type of knowledge in which it clarifies how a particular thing can be accomplished. It is not so popular because it is generally not used. It emphasize how to do something to solve a given problem. Let's see it with an example: var a=[1, 2, 3, 4, 5]; var b=[]; f
2 min read
Difference between Functional Programming and Object Oriented Programming
A programming paradigm is a style, or “way, ” of programming. Programming paradigms differ from one another based on the features and the style they support. There are several features that determine a programming paradigm such as modularity, objects, interrupts or events, control flow etc. Every programming paradigm has its own advantage so, it be
2 min read
Difference between Structured Programming and Object Oriented Programming
1. Structured Programming :Structured Programming, as name suggests, is a technique that is considered as precursor to OOP and usually consists of well-structured and separated modules. In this programming, user can create its own user-defined functions as well as this methodology tries to resolve issues that are associated with unconditional trans
3 min read
Difference between Programmable Logic Array and Programming Array Logic
Programmable Logic Array (PLA) and Programming Array Logic (PAL) are the categories of programming logic devices. In PLA or Programmable Logic Array, there are massive functions can be implemented. Whereas in PAL or Programmable Array Logic, there is finite functions can be implemented. The distinction between PLA and PAL is that, PAL have programm
2 min read
Difference between Python and Lua Programming Language
Python Python is one of the most popular and powerful scripting languages that works nowadays. It is a high-level interpreted programming language. It is a very simple scripting language and very easy to learn as compared to other languages. Python programming language is best for both scripting applications and as standalone programs along with th
3 min read
Difference Between Programming, Scripting, and Markup Languages
When it comes to making a website or app coding involves basically three types of languages i.e the programming language, Scripting Language and Markup Language. There are a lot of people who consider coding as just developing or making a website but they need to understand every single language fits into a particular category and we need to know w
4 min read
Difference Between Go and Python Programming Language
Golang is a procedural programming language. It was developed in 2007 by Robert Griesemer, Rob Pike, and Ken Thompson at Google but launched in 2009 as an open-source programming language. Programs are assembled by using packages, for efficient management of dependencies. This language also supports environment adopting patterns alike to dynamic la
2 min read
Difference between Pair Programming and Peer Reviews
Pair Programming: Pair programming is a component of extreme programming. It works on the principle that two people forms a pair and are definitely better than one. It involves analysis of the hypothesis for the design before it is being created. It requires real time interaction between the members of the pair. Pair programming can be used for bot
3 min read
Difference between N-version programming and Recovery blocks Techniques
Software fault-tolerance techniques use two common techniques to achieve fault-tolerance. 1. N-version programming : In N-version programming technique, there are N groups or individual of developers that do not share the programming process and these independents develop N versions of software module. The idea behind this technique is that differe
2 min read
three90RightbarBannerImg