Differences between Imperative Programming and Declarative Programming

Dan Dias Abeyesinghe
Javarevisited
Published in
2 min readSep 8, 2021

--

Photo by James Harrison on Unsplash

A brief introduction to Programming Paradigms.

As we all are well aware of all the different kinds of programming languages that are used by developers, they all follow an important thing when it comes to programming and that is the method or the strategy they follow.

This can be simply defined as paradigms. Programming paradigms are a method or a strategy that is followed using all the tools that are available following a certain approach to do a certain task or solve any kind of a problem.

Imperative programming

This is a paradigm where a programmer instructs on how to achieve the required task or goal.

This is based on the Von Neumann architecture and contains assignment statements to change the state of the program and thereby finally storing the result at the end of the program.

This describes the control flow of the computation and the user is allowed to make decisions and commands to the compiler.

This is further divided into 3 categories namely, Procedural Programming Paradigm, Object-Oriented Programming, and parallel processing Approach.

Declarative programming

This paradigm is where the programmer explains the logic (logic of computation) behind the desired output rather than focusing on how to actually do it.

This mainly focuses on what needs to be done rather than how it should be done which is going into detail on how the code works. In this the compiler is allowed to make decisions.

This is also further divided into 3 main categories namely, Logic Programming Paradigm, Functional Programming, and Database Processing Approach.

The main difference between Imperative programming and Declarative programming is that Imperative programming focuses on how to do it and Declarative programming focuses on what to do.

I hope this short article on the brief introduction to Programming paradigms and differences between Imperative and Declarative programming helped you to get a better and a clear understanding of the discussed topics. Please do feel free to provide feedback on the above and do follow for more articles related to this and many more!

--

--