News for hackers. Stuff that matters.
Re:Show HN: SyncedStore CRDT – build multiplayer collaborati... by JoeOfTexas on Thursday December 09, 2021 @10:39AM (#29498574)
Pretty interesting project. I'm curious what the data structure looks like that is sent over the network for diffs. I found the part about state-vector, but not about the actual data.

Does it diff the JSON string, or the objects/array themselves? Does it serialize the data or leave as plain text?

I ask, because I have a similar setup, that needs to sync dynamic data structures, but also keep the data deltas as small as possible when sharing them as JSON strings to save bandwidth.

Re:Show HN: SyncedStore CRDT – build multiplayer collaborati... by YousefED on Thursday December 09, 2021 @01:16PM (#29500911)
It doesn't do any diffing, but keeps track of operations underneath, and syncs those. The gist is something like this: - if you push a string "hello" to an array, it will sync an update [push "hello" to Array x] along with some metadata - if you modify a property "prop" and set it to "value" it will sync an update [set "prop" to "value"] along with some metadata

It will not automatically diff these with the previous value (in a distributed system it's difficult to say what the "previous value" was, but it will sync only those properties that have been changed). For text heavy operations, you can use the Text structure which will sync fine-grained operations ([delete 4 characters at position 2] or [insert "world" at position 5]). This makes it suitable for collaborating on rich text documents (similar to Google Docs), see: https://syncedstore.org/docs/advanced/richtext.

This might also be an interesting resource to learn how the Yjs internals work (SyncedStore builds on top of this): https://github.com/yjs/yjs/blob/main/INTERNALS.md