Lists don't make good HN submissions—they're too generic. The only thing to discuss is the lowest common denominator of the items on the list, and that's usually some very general topic about which there's nothing particularly new to say. Also, HN is itself a list. A pointer to a pointer to a pointer is too much indirection!
It's better to post the most interesting item on the list. That increases the chance that there's something specific to talk about.
Well, lists do make good bookmarks, and people tend to favorite things they want to look at later, so your comment and mine are quite compatible.
My concern is thread quality. Lists of "resources about X" don't have anything really to discuss beyond "X in general", and maybe supplying links that didn't make the list. That's not, in the general case, enough to support a curious conversation—when it comes to forum threads, "generic" implies "shallow" and "repetitive".
In this case the thread wasn't so bad, probably because CRDTs aren't in the most-discussed-topic set [1]. So as a generic submission it's better than, say, a list of Rust resources or something [2]. Still, we have to derive moderation principles for the general case, and this principle (about lists) is surprisingly reliable and solid.
My understanding is that CRDT's rely on having a safe place to store data on the user's machine (otherwise it's a bit like doing a `git clone` to receive new data, rather than a `git pull`).
Is this not a major limitation for people hoping to use it for web apps?
> “Distributed state is so fundamentally complex that I think we actually need CRDTs (or something like them) to reason about it effectively.”
Gamedevs working on multiplayer FPSs and MMOs (which requires resolving incredibly complex state synchronizations at millisecond-scales) have done this for decades, and they haven’t been using any fancy CRDTs. Maybe they might have some ideas on how to achieve fast document synchronization as well?
If you forget about P2P and only think about server/client type connections (since P2P doesn’t give you that much advantages in a Google-Docs type service), I think there’s a lot of overlap between multiplayer games and collaborative document editing, and maybe some cross-domain pollination might be needed to solve this problem.
Realtime multiplay state sync isn't remotely like CRDT, it's an endless series of hacks where you attempt to send as little data as possible to have the best player experience as possible. Total smoke and mirrors.
It's fantasy to assume a client has any real "truth" about the world over the span of milliseconds, and in practice you want the client to be as ignorant as possible because cheat programs will let people see through walls, see across the map, etc.
You compensate through speculative prediction to try and make things like movement or gunshots feel lag-free, but again it's smoke and mirrors and a hundred things can cause that to go wrong. How do we resolve mis-predictions to the player? Hide it as best as possible through VFX is a great technique, or hope the users don't notice that a couple of their bullets had exactly zero effect because the server decided you shot outside the rollback buffer and didn't actually hit that other player.
It's very game-dependent too. Valorant hits a 120hz tick rate through insane optimization, and if you have a low-latency connection your view of the world will be much, much more in sync with truth compared to a game like PubG that early on had a tick rate around 15hz (oof).
It's always been a bucket list gamedev goal of mine to work on realtime multiplayer, but after a couple years of doing it I find myself fantasizing of a world where everyone is playing on a computer that isn't a potato with a connection that isn't jittery.
The major difference in constraint is how much user intention/data it's acceptable to discard, especially when a user message arrives later than expected.
In a multiplayer game, it's fine to discard all user intention that arrives a few minutes "late" - gameplay has moved on, and the client should discard local state and just use the server state. But this is totally unacceptable for a text editing application.
CRDTs or Operational Transforms are strategies that allow accepting user edits and preserving their intention even if the user is days or weeks behind or diverged from the server state. I'm not aware of a real-time multiplayer game that allows such high latency for user input.
So the primary reason of CRDTs is to enable offline editing?
The issue is, I don't think CRDTs will help with offline editing either. If the user edits are days / weeks behind and the documents have severely diverged, then merging two documents becomes less of a theoretical logic problem and more of a pragmatic domain-specific problem that might even require the input of the user (like a merge-tool). CRDTs will ensure that the output is deterministic and correct, but it will not guarantee how "natural" or "reasonable" the output will look, and I think you would have to eventually use a bunch of clever heuristics or even provide a mergetool for the user to cleanly resolve differences.
I guess, offline is relative? Most games I play consider >300ms ping to be offline, but I should be able to edit a document with >300ms ping. That said, a lot of CRDT research is focused on totally local, peer to peer editing.
> it will not guarantee how "natural" or "reasonable" the output will look
I don’t think your assumptions are correct. CRDT algorithms designed for text structures like those used by Automerge (RGA) or Y.js (YATA) do a good job preserving user intent even for concurrent edits to a text. Users won’t end up with the letters in a sentence interleaved, and it’s actually pretty rare in to encounter concurrent insertions at the same position - those are the most troublesome for both time complexity and intention preservation. Most other kinds of document edits - like edits on a order of paragraph items - are much easier.
Everything is "possible" in terms of mapping but CRDT's requires one to reformulate problems and it makes a whole lot of things more complicated without really solving GAME sort of problems.
That said I think games are in many cases behind (except fighting games because they care a bit more about outcome accuracy), I think a big part of it is that most rely on pre-made physics systems that might be impressive at rolling around particles and ragdolls but are not designed for multiplayer games to the slightest so they kinda start blowing up when you start mucking around with their states (I suspect this is why fighting games are ahead imo since they often has bespoke essentially 2d sims).
I actually implemented a coop multiplayer prototype over WebSockets for a wolf-style raycasting FPS game I had made for 7dfps that was based on OT (like many fighting games are). It's fairly simplistic (if you bring over the collision and physics work inside the OT simulation).
OT was a good choice since it would eliminate desynchronization issues, and since I was using websockets that are reliable and but can have some lag getting things reliable from the get-go was a better option.
---
1: The server runs a single truth state a second or so back in time (sent over to clients upon connection).
The server never re-simulates anything (clients will, see below)
2: The server keeps a log of events back to the truth cutoff point, once the truth cutoff is passed they're not needed by the server anymore (unless some laggy client hasn't received them yet, but if that clients goes too far behind it should be dropped so no issues for the server about overflowing).
3: Upon connecting clients synchronize time with the server before receiving state and all existing messages.
4: New game states are produced immutably from the previous (with any messages tied to the point in time).
5: When shooting,etc the client sends a timestamped message to the server, the server MIGHT elect to discard or re-time any message a client sends before logging and broadcasting (this is why the time synchronization earlier was important, clients should be created at the "now" point in time or might be re-timed by the server to deter hacking).
6: A client keeps all states between the truth and now, the server will inform clients as the truth moves forward in time so they can discard old states, any message can come from the server as being timed between truth and now and all "old" messages causes a rebuild of states between the message time and "now" (The "now" state is what we display to the user)
7: A client display-cache synchtonizes with "now" and renders, if a server sent "old" messages that caused an enemy to change direction back in time the cache will handle tweening or snapping (and this is totally separated from the simulation).
Since the client created a message at "now" it would've been sent directly to the display cache (and triggered immediate feedback to the user), past changes by the server can undo things (f.ex. if you just died before shooting) but handling that smoothly is not related to the simulation code that can remain clean but rather the display cache handler.
---
Sadly I only did this as a side-project and some contracts took over so it's been kinda bit-rotting after I left it mid-refactor (it was kinda messy and tied to the game it was written for), but the architecture felt quite stable once working (one minor issue might is that it works best with fixed-point math due to floating point numbers potentially diverging, even if gradual checkpoints by the server could be introduced).
> Gamedevs working on multiplayer FPSs and MMOs (which requires resolving incredibly complex state synchronizations at millisecond-scales) have done this for decades
No they haven't. Servers crash and players drop all the time, and many things otherwise don't always act as intended. But practically it doesn't matter because nobody, not the developers and not the players, cares about whether or not their FPS is byzantine fault tolerant.
I mean, they aren't perfect, but you've got to admit they were solving a hard problem with immense technical constraints. And they certainly care about robust synchronization, since subpar netcode can absolutely determine the success or failure of certain types of games (shooters, fighting games). Players always whine about netcode all the time, although 100% byzantine fault tolerance is not the goal.
Speaking of which, do you really need byzantine fault tolerance in a document editor? I mean, it would be really great if it were possible, but given the vast number of different operations you can perform in a document it seems like a really daunting task to do so both formally and practically. And Google Docs isn't really comparable to Bitcoin or airplane control systems anyway. Perhaps temporary periodic backups (like saving diffs to documents in 5-second intervals for a recent period window, so you can rollback if things seriously fuck up) as an escape hatch would be good enough?
CRDT is actually "the tricks we have always used + math to prove whether they work or not". Read the papers. You'll find old school stuff like Lamport Clocks.
> Gamedevs working on multiplayer FPSs and MMOs (which requires resolving incredibly complex state synchronizations at millisecond-scales) have done this for decades
...no they haven't? Those aren't distributed systems. There is an authoritative server that holds the source of truth, and players sync up with it.
A truly distributed game would have each game client contain the full world state, and would synchronize with every other player rather than an authoritative server.
Maybe CRDTs are useful for implementing chat systems since the operational semantics for it are simple enough to make a CRDT system for it?
The blog post I've read in the first link seems to say that CRDTs gets very complex when applying it to a domain where there are all kinds of different rich operations. I guess CRDTs aren't fundamentally the right solution for the collaborative document editing problem then?
First of all, why do you need serverless P2P on a collaborative document editor? I can't really think of any substantial benefits of doing so.
And If you're actually worrying about centralization, then why can't one user run the server as well as the client (which, reading some posts about CRDT performance, should be faster than the overhead of maintaining CRDTs anyway?)
At least just write out the name in full before using the acronym. "CRDT" could mean literally anything and it doesn't help when half the links in the list also don't bother to name it before using the acronym.
Resist using acronyms before defining them. Don't just do it because everyone else does it. You are only creating barriers for people who might be interested in what you are talking about. I know people do this intentionally too. Don't be so insecure. You don't need to invent special language to remain relevant.
Since no one else defined it, CRDT = Conflict Free Replicated Data Types.
There are 2 variants which confusingly have a very similar acronym:
- CmRDT: Commutative Replicated Data Types (also known as operation-based CRDTs). These CRDTs replicate state by transmitting update operations to peers. Peers are always able to apply these operations in any order and without conflicts.
- CvRDT: Convergent Replicated Data Types (also known as state-based CRDTs). These CRDTs replicate state by transmitting the entire object every time an update is made to a local replica. Peers are able to merge the state they receive with their local copy without conflicts.
Off topic - probably the most successful piece of "content" I've ever made is the CRDT notes [1] item that's nestled in there. I saw this submission and thought, "I wonder if my repo made it in there" and indeed it did.
Why I find that funny is that I made that repo on a whim while I was doing my own reading, and then did nothing with it. Maybe I tweeted it? But somehow it SEOed well with Google for a stretch and I've been getting a steady stream of stars on that repo ever since. I assume it was because I created it when CRDTs were still early and so it got the clicks.
I'm sure a lot of folks here know what it's like to try to put projects out there and go looking for traction. It's always made me chuckle that one of my biggest successes was the unintentional one.
I mean.. data, right? I'm trying to learn about CRDTs for complex, nested data structures. The use cases are for.. well, nested data, anything you'd use BTree's and etc for over distributed systems.
A big thing i'm currently learning with them is to write a content addressable system with a more forgiving merge policy between parties.
Yea i often see people nitpick CRDT about user intention, and where it should be `ADBC` or `ABCD`, but in my case i'm focusing on multi-device, not multi-user - and even in multi-user it's still best-in-breed when you are designing away from centralization.
I'm still struggling to learn the more complex approaches to CRDT. So many resources focus on the low hanging fruit of CRDT. Grow counters, basic text editing, etc. I need to build the full suite of data structures; maps, sets, lists, etc.
Ha ha! I'm not a dev any more, but old habits die hard, I guess. My comment was, in fact, to confirm for anyone who wanted to access with mobile Safari but who hadn't yet, that it indeed would work fine.
I have implemented a CRDT system and have also blogged about it afterwards. So I can confirm this.
Joking aside though, CRDTs are still a pretty esoteric space and all the various blog posts came in handy when I was researching how to build my own CRDT.
Most of the resources I've seen on CRDTs are from whitepapers and those can be difficult to read if you don't have a math background. I gave a talk at a Papers We Love [1] explicitly because I found the academic papers a big turn off from many people interested in the space.
It's better to post the most interesting item on the list. That increases the chance that there's something specific to talk about.
https://hn.algolia.com/?dateRange=all&page=0&prefix=true&sor...