Real-Time Collaboration

Published on Nov 6, 2020

Multiplayer is the norm in the gaming industry. It wasn't as commonplace back when I was a child, so my brother and I were extra careful about the games we bought regarding that.

Multiplayer meant playing with friends, so it was a good excuse to have them come over and have a great time. That was before the rise of the massively multiplayer online games we have nowadays.

Similarly, collaborative features have yet to be the norm in the software industry. They are often nice-to-have premium features, rather than a real need. Real-time collaboration is even rarer.

I think it's starting to change thanks to the pandemic and technologies like Web RTC or Web sockets that are becoming easier to integrate. Even though these technologies have been around for a long time, the concrete implementations and the full-fledged libraries are only getting better.

I spent the last 3 days tinkering with a Javascript package called yjs, and I'm truly amazed by its capabilities to power true collaborative experiences. Real-time collaboration is quite hard to implement because changes happen in parallel, by definition. You are bound to encounter conflicts between changes, so the problem is to tell our application how to handle such conflicts in an efficient manner.

Developers are familiar with git versioning, but in a real-time environment, we can't possibly ask the participants to resolve each conflicting change to obtain a single source of truth. So instead of having a formal git-like workflow, we use algorithms to solve them as best as possible without the need for a human to intervene.

Most algorithms work well for small documents, it gets really hard to handle all the conflicts at scale. That's why only 50 people can access a given Google Docs at the same time.

Recent solutions like yjs however, implement new algorithms that scale much better and take the whole collaborative experience to a whole new level. It even works when one of the participants perform changes while being offline, with very little extra code.

I'm quite excited to see where the space goes, as it will certainly unlock a new generation of collaborative products.