In part 1 of this series, we found that users generally view the most popular collaborative text editing algorithms (including the most popular library, Yjs) as silently corrupting their documents when the algorithms resolve direct editing conflicts. We argued that, while this is potentially ok for live collaborative editing (since presence cursors help users to avoid direct editing conflicts), this property makes them generally wholly inappropriate for the offline case, as users will have no ability to avoid such conflicts.
This time, in part 2, we’re going to argue that these same popular algorithms—and Yjs in particular—are also currently inappropriate for the live-collab case. Mostly it comes down to two points:
We’ll describe several specific challenges we experienced as we tried to bring Yjs to our production text editor.
We recommend a less-well-known alternative to Yjs because it is uniformly better on every axis except truly-masterless peer-to-peer editing.
Demo time: the simple solution (~40 lines of code)
I have heard the argument more times than I can count: CRDTs are operationally complex, but you need them (need them!) for optimistic updates, edits during network blips (or extended disconnection), fine-grained provenance of edits, peer-to-peer reconciliation, and so on. I want to convince you that all of these things (except true master-less p2p architecture) are easily doable without CRDTs.
Yes, easily doable: 40 lines of code (291 if you insist on counting the React scaffolding).
Below, this code is running as a live demo. You can use the Pause button to simulate network disconnect. Edit the documents and unpause to see them synchronize, exactly like they would with a CRDT.
Note: offline reconciliation always produces odd results. We talked about this extensively in part 1. All offline-capable reconciliation algorithms (e.g., CRDTs, OT, and this one) choose resolutions at basically-random. The point is not that this algorithm does better, it’s that it does the same thing as CRDTs, but with vastly less complexity.
How the simple thing works
... continue reading