Functional Programming
Resources & Articles
Linus Torvalds on C++ http://harmful.cat-v.org/software/c++/linus (opens in a new tab)
Joe Armstrong http://harmful.cat-v.org/software/OO_programming/why_oo_sucks (opens in a new tab)
Simon Peyton Jones https://www.youtube.com/watch?v=iSmkqocn0oQ (opens in a new tab)
State is the root of all evil. In particular functions with side effects should be avoided.
Terminology
- Pure functions: No side effects, predictable, the same input always returns the same output
- First-class functions: when functions in a language are treated like any other variables
- Avoid Mutations: changing the value assigned to a variable, setters, change an object/array...
- Isolate Side-effects: mutations, I/O...
- Memoïsation: if a function is predictable, the input-output map can be cached
- Currying: f(a, b) becomes f(a)(b), favors reuse of partial functions