HackerTube 中文?
Software boundaries and change →

Can one record tell you both now and then?

Two reads disagree. First ask which moment each value describes, then who can change it. Keeping history and coordinating writes solve different problems.

Questions in this reading · 15
  1. What did the record say at the time?
  2. Can a later update invalidate an earlier fact?
  3. What does a snapshot promise its reader?
  4. Why does shared mutable state tangle a program?
  5. Does hiding mutation remove coordination costs?
  6. Who coordinates access to the same record?
  7. Why don’t two locked objects make a safe transaction?
  8. If replicas agree, did both operations survive?
  9. How can a backup lose money using only committed reads?
  10. How much work keeps an apparently unchanged bit unchanged?
  11. Do gradual replacement and copying leave the same history?
  12. How much entered today and how much remains now?
  13. The branch name stayed the same. Why did the code change?
  14. Do five replicas also create five guessing budgets?
  15. Which version of the rules do you need to replay yesterday?

What did the record say at the time?

Access patterns determine how to organize a store. Retaining historical facts determines which past questions it will ever be able to answer.

Compare original passages and timestamps · 2
understand every access pattern I need to know
AWS re:Invent 2018: Amazon DynamoDB Deep Dive: Advanced Design Patterns for DynamoDB (DAT401) · ▶ 27:59–28:05
no they don't because facts incorporate time how is
The Value of Values with Rich Hickey · ▶ 20:30–20:41

Can a later update invalidate an earlier fact?

State makes an answer depend on when you ask. Recording time with a fact lets two different answers describe different moments without contradicting each other.

Compare original passages and timestamps · 2
Having state in your program is never simple, right?
"Simple Made Easy" - Rich Hickey (2011) · ▶ 36:01–36:08
no they don't because facts incorporate time how is
The Value of Values with Rich Hickey · ▶ 20:30–20:41

What does a snapshot promise its reader?

Stable snapshots let observers read a particular version. Treating information as values explains why that version can be passed on without changing its meaning.

Compare original passages and timestamps · 2
key characteristic of a value is that it's immutable
Are We There Yet - Rich Hickey · ▶ 24:48–24:53
values are immutable right and values are semantically transparent
The Value of Values with Rich Hickey · ▶ 10:43–10:54

Why does shared mutable state tangle a program?

One talk separates identity from its successive values. The other shows how state couples parts of a system through time. Read them together to identify what a caller must know about earlier operations.

Compare original passages and timestamps · 2
key characteristic of a value is that it's immutable
Are We There Yet - Rich Hickey · ▶ 24:48–24:53
Having state in your program is never simple, right?
"Simple Made Easy" - Rich Hickey (2011) · ▶ 36:01–36:08

Does hiding mutation remove coordination costs?

An object can conceal its state and still require callers to coordinate operations. Examine what happens when independently safe operations must work together.

Compare original passages and timestamps · 2
They hide mutation – they mutate some state inside, right?
Category Theory 1.1: Motivation and Philosophy · ▶ 10:48–10:57
feels like an immutable object, except that it has state inside it.
How To Design A Good API and Why it Matters · ▶ 41:10–41:16

Who coordinates access to the same record?

Designing a table around queries addresses how data is laid out. Routing operations to one process addresses how simultaneous work on a record is coordinated.

Compare original passages and timestamps · 2
access on a single record is going through a single process
Erlang Factory 2014 - That's 'Billion' with a 'B': Scaling to the Next Level at WhatsApp · ▶ 14:38–14:43
understand every access pattern I need to know
AWS re:Invent 2018: Amazon DynamoDB Deep Dive: Advanced Design Patterns for DynamoDB (DAT401) · ▶ 27:59–28:05

Why don’t two locked objects make a safe transaction?

Compare what each lock protects with what the combined operation requires. This is a cost of coordinating shared mutable state, not a claim that every lock is wrong.

Compare original passages and timestamps · 3
values aggregate to values all the benefits apply to Aggregates
The Value of Values with Rich Hickey · ▶ 16:07–16:16
and unfortunately locks don't compose either, right. That's the problem with locks.
Category Theory 1.1: Motivation and Philosophy · ▶ 12:16–12:26
as soon as you have objects being shared encapsulation just flies out the window
Object-Oriented Programming is Bad · ▶ 20:59–21:10

If replicas agree, did both operations survive?

Two ATMs can each see the same hundred-dollar balance. A check and its debit must form one operation, or two individually valid decisions can jointly overspend. A collaborative editor faces a different concurrency problem: both users inserted a character. Choosing a single timestamp winner can make replicas agree while losing an insertion. Kleppmann explores operations that converge across delivery orders. Start by naming the invariant: a dollar cannot be withdrawn twice, whereas both edits may deserve preservation. Replica agreement alone does not settle either requirement.

Passages and timestamps · 3
the account balance check and the withdrawal are basically done not at all or in full
Lecture 1 | Programming Paradigms (Stanford) · ▶ 10:05–10:14
as being the winner and the other ones were just going to throw away
Conflict Resolution for Eventual Consistency • Martin Kleppmann • GOTO 2016 · ▶ 16:19–16:23
apply operations in a different order and still get the same outcome
Conflict Resolution for Eventual Consistency • Martin Kleppmann • GOTO 2016 · ▶ 29:38–29:46

How can a backup lose money using only committed reads?

Two accounts start with $500 each. A backup reads the recipient at $500. A $100 transfer then commits. The backup reads the sender at its new balance of $400. The backup totals $900, although the accounts always held $1,000 between them. Each read can be committed while their combination describes a balance that never existed. Kleppmann uses this to distinguish a row from a snapshot. Hickey approaches the write side with Clojure refs: choose the identities that must change together and let readers observe a consistent point. Retaining immutable values still leaves the question of which values belong to one observation.

Passages and timestamps · 2
you've seen different parts of the database at different points in time
"Transactions: myths, surprises and opportunities" by Martin Kleppmann · ▶ 16:34–16:42
refs allow you to change more than one thing in a coordinated operation
Clojure Concurrency - Rich Hickey · ▶ 61:50–61:59

How much work keeps an apparently unchanged bit unchanged?

A caller keeps reading the same bit while charge leaks from the underlying DRAM cell. The animation follows the bank’s refresh cycle. A promise that a value remains readable over time therefore depends on a separate operation meeting its own deadline, even when no caller writes a new value.

Passages and timestamps · 2
charge leaks out over time.
How does Computer Memory Work? 💻🛠 · ▶ 21:33–21:39
The refresh operation occurs once every 64 milliseconds for each bank
How does Computer Memory Work? 💻🛠 · ▶ 22:53–22:58

Do gradual replacement and copying leave the same history?

The teleporter thought experiment deliberately matches the copy’s measurable attributes. The ship example instead preserves a sequence of replacements. In a version system two byte-identical files pass a content check, while tracing which review produced one requires its history. Decide whether the question concerns present content, provenance or continuity before choosing the record.

Passages and timestamps · 2
Or a copy that thinks it's you?
Why Teleportation Would Kill You · ▶ 0:48–0:51
eventually no piece is original.
Why Teleportation Would Kill You · ▶ 2:33–2:39

How much entered today and how much remains now?

Grey points out that material is being processed while intake continues. In a simple container, a total inflow with unknown arrival and departure times does not determine the contents at a particular instant. Before reconstructing a snapshot from a daily total, decide whether the series records events, net changes or current state.

Passages and timestamps · 2
It takes about 40 coffee beans to make one shot of espresso.
Your Coffee Addiction Is Probably Good for You · ▶ 0:57–1:01
while you're busy getting the coffee in, your body is busy getting it out
Your Coffee Addiction Is Probably Good for You · ▶ 1:48–1:56

The branch name stayed the same. Why did the code change?

Sending a colleague a branch name does not hand over a fixed version. In the lecture’s cat-and-dog example, a new commit moves the cat reference to a new node while existing commits and parent relationships remain. Separate a changing identity from its value at one moment: a branch name tracks ongoing work, while a commit identifier names a particular snapshot. To explain yesterday’s behavior, record the commit to which the name resolved, then ask whether inputs and the execution environment were preserved too. A code snapshot answers one layer of the question; a commit ID alone does not establish reproducibility of an entire run.

Passages and timestamps · 2
this entire graph is actually immutable.
Lecture 6: Version Control (git) (2020) · ▶ 24:15–24:17
the cat pointer, will be updated to point to the new commit
Lecture 6: Version Control (git) (2020) · ▶ 51:27–51:32

Do five replicas also create five guessing budgets?

History can be copied, but an allowance for failed attempts must not grow freely with the number of replicas. Krstić explains that five HSMs with ten independent attempts each would multiply the total guessing budget. In the design he describes, members retain failure counts but recovery requires a majority commit; an isolated replica cannot keep offering a fresh independent allowance. The coordinated state determines whether the next request is permitted, rather than merely recording what happened afterward. Draw the number of stored copies separately from the authority to consume an allowance. Redundancy and authorization must be designed together; replica count alone establishes neither availability nor security. The claimed guarantees remain bounded by the protocol and trust assumptions in this vendor presentation.

Passages and timestamps · 2
every new unit you escrow to increases that maximum failure count
Behind the Scenes of iOS Security · ▶ 30:10–30:21
a majority quorum is required to proceed
Behind the Scenes of iOS Security · ▶ 31:22–31:27

Which version of the rules do you need to replay yesterday?

Michael Schwern explains a Git branch as a label pointing to a commit. The label can move, and the earlier commit is still visible in the history in his example. Tom Scott uses time zones to illustrate another kind of changing information. He urges keeping the rule file up to date, because a fixed offset cannot cover the rules of every place and date.

Explaining yesterday’s result starts with keeping its inputs. It also requires recovering the code or rules in use at the time. If the system stores only a name that always points to the current version, the old inputs alone may not reproduce the result.

Passages and timestamps · 2
just adding a label
[Linux.conf.au 2013] - Git For Ages 4 And Up · ▶ 23:25–23:29
as long as you keep that file updated
The Problem with Time & Timezones - Computerphile · ▶ 3:38–3:41

Try it on your own example

If two requests update one account, what can a reader see, and can you recover the previous value later?