What does HackerNews think of yjs?

Shared data types for building collaborative software

Language: JavaScript

#9 in P2P
#3 in P2P
I've seen it come up often in collaborative text editors.

Also see: https://github.com/yjs/yjs

You are absolutely right that XML is better for document structures.

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...

https://github.com/yjs/yjs/

Most live coding languages relying on SuperCollider can take advantage of the client-server architecture of SC and support collaboration easily. So it's very interesting that the concept of collaboration is highlighted on Overtone website. Is it embedded in the language aspect?

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]).

[1] https://glicol.org/

[2] https://github.com/yjs/yjs

Note: https://github.com/yjs/yjs for collaborative "document edition, and user cursors"; has WebRTC, web socket, matrix.org backend
Anything CRDT (conflict free replicated datatypes: https://en.wikipedia.org/wiki/Conflict-free_replicated_data_...) related is fun to read up on and play with.

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

- https://github.com/partykit/partykit

- https://github.com/firesync-org/firesync

Just use express server and session storage and voila. You can write prototype on repl.it

I would take a look at y.js if you are building shared state - https://github.com/yjs/yjs

For quick viewing, here's how it works in Postgres (using 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