Two people typing in the same paragraph
Why last-write-wins destroys documents, what operational transformation and CRDTs each do about it, and the cost of both.
Two people type into the same sentence at the same time. Sending whole documents means the later save silently erases the earlier one; sending character positions means the positions are already wrong by the time they arrive, because the other person's insert shifted everything after it. This is not a networking problem you can fix with a faster connection: the edits genuinely happened concurrently, and something must decide what the merged result means.
Operational transformation keeps a central server that rewrites each incoming operation against the operations it has already applied, so an insert at position ten becomes an insert at position twelve. It is compact on the wire and it is what several very large editors run on, but the transformation functions are subtle, the server is mandatory, and the correctness proofs are famously easy to get wrong.
CRDTs give every character a unique identity and an ordering rule such that any two replicas that have seen the same edits converge, regardless of order, with no central authority. That buys offline editing and peer-to-peer, and it costs metadata: deletions leave tombstones, documents grow, and a long-lived file needs compaction. Before either, check the requirement. A great deal of what people call collaborative is satisfied by presence indicators, section-level locking and a conflict warning, and that is a week rather than a quarter.
You should now be able to
- Explain why concurrent edits cannot be merged by timestamp
- Describe the difference between OT and CRDT in one paragraph each
- Decide when presence and awareness are enough
Loading…