Skip to content
Related Articles

Related Articles

Improve Article
Difference between Functional and Imperative Programming
  • Last Updated : 15 Mar, 2021

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 to solve problems effectively in a simpler way. It also allows functions to be treated as ordinary values because, in functional programming, functions may freely operate on functions as parameters and return new functions as return values. It is a form of declarative programming. It is considered one of the popular programming paradigms that do computation like mathematical functions without changing state and mutating data.

For Example: Python, Clojure, Haskell, Lisp, etc.

Imperative Programming: Imperative Programming, as the name suggests, is a type of programming paradigm that specifies steps that computers should take to complete or finish a goal. In this, functions are coded implicitly in each and every step that is required to solve a problem. In simple words, it includes commands for the computer to perform. Programs are written more quickly and applications are also easier to optimize. It allows functions to be treated as special case constructs because, in imperative programming, it is rare to allow entire method calls to be returned from a method. It is a form of algorithmic programming.

For Example: Java, Fortran, Pascal, C, C++, etc.

Tabular difference between Functional Programming and Imperative Programming:

Functional Programming

Imperative Programming

It is generally a process of developing software simply by composing pure functions, avoiding or minimizing side effects, shared data, and mutable data.It is generally a process of describing steps that simply change the state of the computer.
It mainly focuses on what programs should be executed or operate i.e., results.It mainly focuses on describing how the program executes or operates i.e., process.
It uses functions to perform everything.It uses statements that change a program’s state.
Its advantages include bugs-free code, increase performance, better encapsulation, increase reusability, increase testability, etc.Its advantages include easy to learn, easy to read, a conceptual model is easy to learn, etc.
Its characteristics include low importance of the order of execution, stateless programming model, primary manipulations units, primary flow control, etc.Its characteristics include a sequence of statements, contain state and can change state, might have some side effects, stateful programming model, etc.
These programs are generally structured as successive nested functional calls.These programs are structured as successive assignments of values to variable names.
In this, the command execution order is not fixed.In this, the command execution order is fixed.
It involves writing programs in terms of functions and mathematical structures.It involves writing programs as series of instructions or statements that can actively modify memory.
It is more expressive and safer as compared to imperative programming.It is less expressive and safer than compared functional programming.
It requires the explicit representation of data structures that are used.It requires data structure to be represented as changes to state.
In this, new values are usually associated with the same name through command repetition.In this, new values are usually associated with different names through recursive function call nesting.
My Personal Notes arrow_drop_up
Recommended Articles
Page :