Imperative
programming is 3rd generation of programming language where the
programmers are concerned with what is required as well as how it will achieved
whereas in Functional programming language programmers are concerned with only
what is required, not with how to achieve it.
Imperative
programming treats both functions and data independently whereas for Functional
programming data and functions are one and a same thing. Functional programming
does not support side effects as there is no mutable data in functional
programming as there is no variable assignment that is why functional programs
are also known as stateless programs.
Functional
programming supports Lazy Evaluation sometimes referred to as “Call by Need” where
first the function is evaluated then the arguments whereas Imperative supports
Eager evaluation i.e. evaluate the argument first then the function.
Functional
programming has various features that are foreigners to Imperative such as
currying, partial execution of function, side effects, pure functions,
referential transparency etc.
The concept
of looping is not present in Functional programming instead it uses Recursion
as a substitute to looping constructs.
Functional programming
also supports automatic memory management and garbage collection however some of
the imperative programming language do supports but not all.
Functional
programs are often shorter and easier to understand than their imperative
counterparts. Since various studies have shown that the average programmer's
productivity in terms of lines of code is more or less the same for any
programming language, this translates also to higher productivity.
No comments:
Post a Comment