You're viewing the readable version of this site. The interactive extras (search, diagrams, read-aloud) need JavaScript and a current browser. Enable JavaScript; if it is already enabled, update your browser.

Learn · Hidden Machines · Part V

budding

A Change Is Something You Can Carry

Deltas, event folds, checkpoints, and replay limits.

incremental-computation, event-sourcing, deltas, replay, learn

You will model changes as values, compose them, and distinguish deltas from durable events whose fold can rebuild current views.

Stop comparing two whole worlds

An editor sends old and new documents through parsing, indexing, and rendering. Each stage diffs them again. The same information is repeatedly rediscovered. Represent the edit once: insert, delete, or replace with a location and payload.

Discrimination — choose the value that preserves the needed fact.

Deltas have composition: apply change d1d_1, then d2d_2, or compose them into one change with the same observation. The exact representation depends on the carrier; text edits, set additions, and numeric differences have different algebras.

Durable events make current state a fold only when they retain every required fact. A reducer starts from an initial value and applies ordered events. A checkpoint caches a fold prefix, but the event suffix remains authoritative. Replay must rebuild projections without repeating external effects; effects are consequences handled when the event is first admitted, not instructions inside the historical fold.

Where the model stops

Not every snapshot should become an event log. If history has no product or audit value, snapshots plus explicit deltas may be simpler. An event omitted for privacy cannot later support a projection needing that fact. Checkpoints optimize reconstruction; they do not repair insufficient events.

Lessons

  • Deltas carry change instead of forcing repeated snapshot comparison.
  • Composition must preserve the effect of sequential application.
  • A view is a rebuildable fold only over sufficient durable events.
  • Replay never repeats external effects.

Practice

  1. Compose two insertions into a text delta and note how positions shift.
  2. Distinguish a UI changed signal from an auditable domain event.
  3. Transfer event folding to build status or inventory balance.

Once change is explicit, how much of the dependency graph must see it?

References

  1. Umut A. Acar, “Self-Adjusting Computation”.” — foundational change-propagation work.
  2. Martin Fowler, “Event Sourcing”.” — the production pattern and replay distinction.