In fact, there are a lot of kinds of app that you can build with front end code only. You now only kind of have to make three tech choices or even less. And you have very little to deploy because again, you might only need to deploy a static front end and maybe some lightweight back end workers, not a whole stack.
How can this be possible? The first ingredient that I had to discover that really gave me the idea to build a framework like this and that made me think in this different way is something called CRDTs. You might or might not have heard of them. The abbreviation stands for conflict-free replicated data types. And a very quick, simple way to think about them is that they are Git for data.
To be more precise, it's super fast Git for lots of tiny data. And you can run that on the client. And that's really what makes hard things like I talked about earlier, really easy suddenly. For example, real-time multiplayer. Well, and if you've got a super fast Git for lots of tiny data, I think you can imagine how you could build real-time multiplayer experiences on top of that. You just share the edits and everyone will end up with the same data and you can do that in real time. You might be asking like, okay, part of real-time multiplayer is having user presence, so you can see the other user's curses and so on. How would you add that? Well, the curses are really just more tiny data, so you just also put them in the CRDT and it's super fast, so you can see other people's curses or other kinds of user presence in real time. So, real-time multiplayer and presence solved.
What about cross-device sync? Well, if you think about how you are using Git, you could work on the same repo on different devices and then just use explicit pushes and pulls to get to the same state everywhere. And the same is true for CRDTs, except it kind of happens automatically in real time. Offline support, same story. Of course you can use Git offline. You can work without any internet, do some commits, push it up and it all works and CRDTs are exactly the same. Again, because it's super fast, Git for lots of tiny data.
If you think about it, if you work offline on multiple devices concurrently or if different people work offline on the same data, you inevitably will run into conflicts. And this is where the last really important property of CRDTs comes in, which is that they basically have reasonable auto merging built in. So, even if you go offline, go back online, your changes are synced, most of the conflicts will just be solved in a way that you would expect as a user. And even this radical idea of user file uploads also becomes super simple because you can't just store lots of tiny data in CRDTs, you can actually also store large data in it. And then that large data becomes synced and shared between users just like everything else. So, user file uploads are also very easy. And you might start to see that while the architecture is very different and it might seem like this crazy new way to build apps, I really want to convince you today that it's actually the only sane way to build apps these days.
You might be wondering next about, well, how does sharing work and how do permissions work in this kind of context? And traditionally you do this by kind of centrally enforcing them in the backend at the API boundary.".
Comments