On this page
Functional Programming
Prev: Object-Oriented Programming | Up: paradigms | Next: Declarative & Event-Driven Programming
Rel: Functions & Recursion, Type Systems, Python Iterators & Generators
Ref: Wikipedia — Functional Programming
Tags: #public #prog #programming #paradigms #functional
Contents
- > Pure Functions & Referential Transparency
- > Immutability & Pipeline Composition
- > Functional Core, Imperative Shell
Pure Functions & Referential Transparency
A pure function:
- Always returns the exact same output for the same inputs (deterministic).
- Produces no side effects (no mutating global state, no I/O, no clock/randomness reads).
Because of referential transparency, any pure call can be safely memoized, reordered, parallelized, or tested in isolation without mocks.
Immutability & Pipeline Composition
Instead of mutating a collection in place, functional code composes small transformations (map, filter, reduce / fold) over immutable values:
orders
|> filter(o => o.status == "paid")
|> map(o => o.total_cents)
|> reduce(0, (acc, x) => acc + x)
Functional Core, Imperative Shell
Real programs must perform I/O (databases, network, files). Keep business logic in pure functions (functional core) and push I/O, retries, and state mutation to thin outer boundaries (imperative shell).
Linked from
- tuts/programming/concurrency/synchronization_and_coordination
- tuts/programming/foundations/functions_and_recursion
- tuts/programming/paradigms
- tuts/programming/paradigms/declarative_and_event_driven
- tuts/programming/paradigms/functional_programming
- tuts/programming/paradigms/object_oriented_programming
- tuts/programming/software_design/testing_and_maintainability
Related notes
- tuts/programming/paradigms Linked here; links to this page; shared tags: #paradigms, #prog, #programming
- tuts/programming/paradigms/declarative_and_event_driven Linked here; links to this page; shared tags: #paradigms, #prog, #programming
- tuts/programming/paradigms/object_oriented_programming Linked here; links to this page; shared tags: #paradigms, #prog, #programming
- tuts/programming/foundations/functions_and_recursion Linked here; links to this page; shared tags: #prog, #programming
- tuts/programming/concurrency/synchronization_and_coordination links to this page; shared tags: #prog, #programming
- tuts/programming/data_and_types/type_systems Linked here; shared tags: #prog, #programming
- tuts/programming/software_design/testing_and_maintainability links to this page; shared tags: #prog, #programming
- tuts/python3/tutorials/advanced_python_internals/iterators_and_generators Linked here
- tuts/programming/paradigms/imperative_and_procedural shared tags: #paradigms, #prog, #programming
- tuts/cpp/builtins/lambdas shared tags: #functional, #prog