liveBook · Manning

Functional, stateless philosophy

As explained in Grokking Simplicity

A programming paradigm that emphasizes composing computations as evaluations of functions while minimizing mutable state and side effects.

Functional programming organizes software around evaluations of functions while minimizing unnecessary side effects. Pure functions depend only on their arguments, always return the same result for the same inputs, and are easier to understand and control. Practical functional programming does not eliminate every side effect; it isolates actions that send messages, modify state, or otherwise depend on time. section 1.1 section 1.7

Use the central distinction between three kinds of code:

  • Data is inert, transparent, easy to store, and easy to transmit. section 1.10
  • Calculations produce values without depending on when or how often they run, making them easier to test, reuse, and understand. section 1.10 section 19.3
  • Actions depend on time, ordering, or repetition, so isolate them and give them focused attention. section 1.38 section 19.3

Task completion and email

In a project-management service, marking a task complete and sending an email are actions. Deciding which users should receive notifications is a calculation, while the task, user, and notification details are data. Extracting the calculation from the email-sending action reduces the code whose behavior depends on time and makes the extracted logic easier to test. section 1.11 section 19.3

This perspective remains useful in object-oriented, procedural, and mixed codebases. It supports incremental refactoring rather than requiring a wholesale functional rewrite: identify actions, extract calculations, represent information as data, and concentrate safeguards around unavoidable effects. section 1.36 section 1.38

How Grokking Simplicity covers it

How deep it goes
Explains definitions, tradeoffs, and classification of code, then stops short of language-specific implementation details.
Examples
Uses a task-management service, email notifications, and distinctions among task data, notification calculations, and sending actions.
What it assumes
Assumes general programming familiarity while teaching functional distinctions without requiring a functional language or mathematical background.
What you can do after
Diagnose/debug bugs by identifying actions, then apply extraction of calculations to improve testing, reuse, and understanding.
How it connects
Connects pure functions, side effects, higher-order functions, distributed systems, temporal semantics, and onion architecture.

Also explained in

Compare how 19 books explain functional, stateless philosophy →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking Simplicity. The section links point to the parts of the book it draws on.