Paradigm where programs are constructed by applying and composing functions.
Rather than a sequence of imperative statements, function definitions are trees of expressions that each return a value.
example:
println!("{}", (1..11).fold(0, |a, b| a + b));We are describing what to do rather than how to do it.
fold is a function that composes functions composes functions
See also
- Imperative paradigm β the contrasting paradigm: imperative describes how via mutable steps, functional describes what via expression trees
- h(x) = g(f(x)) β Composing Functions With β and Its Reverse β function composition is the core mechanism of functional programming; fold is composition made concrete
- The Actor Model Isolates State Behind Message Passing, No Shared Memory β the actor model and functional programming share the principle of avoiding shared mutable state; FP eliminates mutation entirely, actors isolate it per actor
- Single Writer Principle, one thread own all writes to a resource β the single writer principle is the concurrency-safe approximation of functional immutability: if you canβt eliminate mutation, at least confine it to one owner
- Tail Call optimization replaces call with jmp β tail call optimisation is particularly important in functional programming because recursion replaces loops; without TCO, deeply recursive functional programs overflow the stack
- Atomic Notes are high cohesion low coupling, reusable in multiple outputs β the software analogy that grounds the atomic note concept: functional programs compose small pure functions the same way a Zettelkasten composes atomic notes into essays