Brian Hicks, December 17, 2024
Since around Thanksgiving, I've been working on the draft of a book I'm tentatively calling "Local-First from Scratch." The idea is basically to write tinyping, but do it in book form.
One thing I had to decide right away was whether this would use some off-the-shell local-first library or if I was going to explain and implement everything from first principles. I chose the latter, which I think will make for a more interesting read, and has a nice side benefit that it doesn't tie the book to the libraries and frameworks that are popular (or exist!) today. Hopefully that will mean that it stays pretty evergreen!
This choice has also made me dive deeply into the theory behind CRDTs. I've found a lot of things that I just misunderstood on previous learning expeditions, just by following the little voice in my head that says "hey… is that right, actually?" I want to get things right so that I'm not misleading people, and that turns out to be a pretty powerful motivator for learning!
I hope that I can ship a first beta version to a small group of readers in the first couple of months of 2025. If you're interested, please get in touch!
Here's a basic outline:
- Introduction: a similar pitch to what I just wrote above, but less meta.
- Foundations: what we're building, why local-first, and what are CRDTs?
- Breaking Ground: Implementing some basic CRDTs (and logical clocks)
- Building an App: Modeling the data in our app based on the building blocks we just implemented.
- First Client: Building a TUI to be able to use the app model we just made.
- Synchronization: Building a server to synchronize data between replicas.
- Second Client: Building a browser-based client using the same codebase and sync server, and extending the app model to support time reporting.
- Sync Revisited: Making the sync protocol way more efficient by only sending the parts of the data that have changed.
- Conclusion: What we've learned, what we could do next, and where to go from here.
- Appendix, Sequence CRDTs: Extending our CRDT building blocks to support sequences.