What does HackerNews think of yjs?
Shared data types for building collaborative software
Also see: https://github.com/yjs/yjs
My current theory is that Yjs [0] is the new JSON+XML. It gives you both JSON and XML types in one nested structure, all with conflict free merging via incremental updates.
Also, you note the issue with XML and overlapping inline markup. Yjs has an answer for that with its text type, you can apply attributes (for styling or anything else) via arbatary ranges. They can overlap.
Obviously I'm being a little hypabolic suggesting it will replace JSON, the beauty of JSON is is simplicity, but for many systems building on Yjs or similar CRDT based serialisation systems is the future.
Maybe what we need is a YjsSchema...
When I develop Glicol[1], I want to build a WYSIWYG style: for example commenting out a line will mute the track. But it brought some challenges to collaboration so I have to build some "consensus" mechanism on top of the Google doc style text co-editing (powered by yjs[2]).
Papers and references (page maintained by central academic in the world of CRDTs): https://crdt.tech
Group doing research into how they can be used to build interesting collaborative (and async) applications: https://www.inkandswitch.com
A few of the major open source implementations - mostly for rich text editing or JSON like data structures:
- Yjs: https://github.com/yjs/yjs
- Automerge: https://github.com/automerge/automerge
- Peritext: https://www.inkandswitch.com/peritext/
- Dimond types: https://github.com/josephg/diamond-types
People building eventually consistent database syncing with them:
- https://electric-sql.com (Postgres <-> SQLite)
- https://vlcn.io (SQLite <-> SQLite)
Open source colaborative servers (coordination, persistance, presence):
- https://github.com/ueberdosis/hocuspocus
I would take a look at y.js if you are building shared state - https://github.com/yjs/yjs
create table posts (
id serial primary key,
content crdt.ydoc default crdt.new_ydoc()
);
insert into posts (content)
values (crdt.new_ydoc());
update posts
set content = content || crdt.new_ydoc()
where id = 1;
The heavy-lifting is done by the teams at Yjs[0] and Automerge[1], who have re-implemented their JS libs in Rust. This made it possible for us to wrap them into a Postgres extension using pgx[2] (which is fast becoming a de-facto tool at supabase)[0] Yjs: https://github.com/yjs/yjs
[1] Automerge: https://github.com/automerge/automerge
[3] pgx: https://github.com/tcdi/pgx