liveBook · Manning

Diff

As explained in Data-Oriented Programming: Reduce software complexity

A diff is a representation of the changes between two versions of structured data.

A diff represents the changes between two versions of structured data. For nested maps, it identifies changed fields and preserves their paths, turning a vague “something changed” into information that reconciliation can use. section 5.2 section 9.4.4

Suppose two mutations begin from previous state. Compare previous with current to see what another mutation changed, then compare previous with next to see what this mutation wants. Disjoint diffs can be combined; overlapping fields indicate a conflict and can cause the mutation to abort. section 5.2 section 5.5

A focused change

Comparing {y: {z: 1}, w: [5]} with {y: {z: 2}, w: [4]} produces a diff containing only y.z = 2 and w = [4].

Figure 5.4 In a three-way merge, we calculate the diff between previous and next, and we apply it to current.

Visualize how a diff from previous to next is applied to current during a three-way merge. section 5.2

How Data-Oriented Programming: Reduce software complexity covers it

How deep it goes
Explains recursive structural comparison and three-way conflict detection, while deferring thread-safe implementation for multithreaded environments.
Examples
Demonstrates changed nested fields and arrays with immutable maps, then tests the resulting sparse structural diff.
What it assumes
Assumes familiarity with nested maps, immutable data, and concurrent mutations while explaining the comparison procedure directly.
What you can do after
Diagnose concurrent state changes and implement recursive diffs for immutable nested data.
How it connects
Connects diffs to three-way merge, optimistic concurrency control, immutable data, persistent data structures, and Git.

Also explained in

Compare how 2 books explain diff →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Data-Oriented Programming: Reduce software complexity. The section links point to the parts of the book it draws on.