Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

What is the difference between functional programming and purely functional programming?


Asked by Bethany Pearson on Dec 04, 2021 FAQ



Functional programming may use persistent non-purely functional data structures, while those data structures may not be used in purely functional programs. Each evaluation strategy which ends on a purely functional program returns the same result.
Just so,
Because pure functions are referentially transparent, we only need to compute their output once for given inputs. Caching and reusing the result of a computation is called memoization, and can only be done safely with pure functions. A variation on the same theme.
Additionally, Functional programming is also declarative programming -- the structure given to your code corresponds to its meaning -- a program is a function that changes the state of the world. Procedural programming is what you'd consider "typical" programming in any C language or its descendants, including OO languages such as Java and C++.
Also,
Functional programming is similar to “pure” mathematical functions. Instead of specifying a procedure to solve a problem, functional programs compose functions to produce the desired result without using ‘state’. Evaluation of these functions and their relationships are much more important than objects and relationships.
In respect to this,
Yes, functional programming is about functions. But imperative programming languages also have functions. Here's the obvious difference: in functional programming you don't have variables of which you can change the value.