Learn · Interactive book
budding
Hidden Machines
From spaghetti to structure — finding the mathematics already inside your code.
The machinery was there before it had a name.
Working code can remain easy to break because its states, relationships, ownership, and laws are implicit. This book teaches a repeatable recovery: inventory what the program can do, find the contradictions, choose the smallest adequate formal object, separate the pure mechanism from effects, and preserve the observations that matter.
This is a budding first edition. Its dependency chain and structural claims are checked, but delayed reader validation is still pending. The chapters favor a complete compact argument over encyclopedic coverage.
The companion Retrieval Route schedules one-day, one-week, and one-month practice without accounts, streaks, or tracking.
Part I — Seeing the machinery
- Too Many Switches for One Light — Boolean flags, result types, and narrowed boundaries.
- Independent Lifecycles Need Independent State — state machines and product automata.
- A Refactor Must Say What Stays the Same — carriers, laws, observations, and equality domains.
- Run the Recovery Yourself — the structure-recovery procedure.
Part II — Programs that remember
- The Newest Messenger Holds the Seal — generation fences and stale-result rejection.
- A Lost Reply Is Not Permission to Repeat — idempotence, operation identity, and reconciliation.
- Await Stores the Rest of the Function — coroutines, suspension frames, and liveness.
- Every Child Needs an Owner — structured concurrency, capabilities, and error kernels.
Part III — Capacity
- Capacity Is Something You Can Spend — semaphores, bounded queues, and resource credit.
Part IV — Lifetimes
- Leave the Room, Clear the Table — regions, arenas, borrowing, and lifetime geometry.
Part V — Change without starting over
- A Change Is Something You Can Carry — deltas, event folds, checkpoints, and replay limits.
- Recompute Only the Dependency Cone — incremental invalidation and affected frontiers.
- Summaries Compose — monoids and measured structures.
- Different Arrival Orders Can Reach the Same State — partial orders and convergent merge.
Part VII — The geometry of interaction
- Every Number Needs a Unit and a Home — quantity types, affine frames, and region algebra.
Part VIII — Teaching tools to see
- The Smell Is Evidence — advisory structure recognition and a complete recovery.
- Leave the Tangle Standing — when recognition does not justify refactoring.
The recovery card
For any unfamiliar tangle, write down eight things before naming an abstraction:
- admissible states;
- events and operations;
- owners and lifetimes;
- observable effects;
- impossible combinations;
- carrier, operations, and candidate laws;
- a counterexample to each law; and
- the case where the abstraction should be refused.
Then apply the adequacy tiebreak: choose the larger structure only if it eliminates a reachable mistake, uses laws the behavior depends on, and has enough honest consumers to justify a shared abstraction.