What is functional programming?
Functional programming (often abbreviated FP) is the process of building software by composing pure functions, avoiding shared state, mutable data, and side-effects. Functions are first class citizens of such languages.
Which is imperative and which is declarative?
FP - Declarative and OOP - Imperative
Where does application state reside in FP vs OOP?
Application state flows through pure functions, as opposed to OOP where the state is usually shared and colocated with methods in objects.
Examples of some functional languages
LISP, Erlang, Haskell, F#, Clojure,
A pure function ____
- Has no side effects
Function composition is ______
Is process of combining two or more functions to produce new function or produce some output.
f(g(x))
Shared state is ______
Any variable, object or memory that is shared scope or is a property of object being passed between scopes.
Problems with shared state
Examples of side effects
What are higher order functions?
HOF is any function which takes function as argument, returns a function or both. They are at higher abstraction levels.
Eg. Monads, Promise, Async etc