Collaborative Editing in CodeMirror

· coding · Source ↗

TLDR

  • Marijn Haverbeke explains why CodeMirror’s upcoming version uses classical centralized OT over CRDTs or distributed approaches, publishing a deliberate negative result.

Key Takeaways

  • 95% of collaborative editing literature targets fully distributed peers; centralized client-server systems need almost none of that complexity.
  • Plain-text OT is straightforward: a transform function adjusts positions across concurrent changes, convergence follows from O(N×M) diamond composition.
  • CRDTs require per-character IDs and auxiliary data structures that conflict with CodeMirror’s goals of huge-document support and a clean API.
  • CodeMirror uses change sets (kept/replaced spans) rather than sequential individual changes, making multi-point edits like wrapping a range natural to express.
  • Distributed CRDT support is explicitly punted; external libs like Yjs can be wired in, as already done for ProseMirror.

Hacker News Comment Review

  • No substantive HN discussion yet beyond praise for the author’s broader work (CodeMirror, Lezer, Eloquent JavaScript).

Original | Discuss on HN