Why We Threw out All Our Code (And Why You Should Too)

This past week, we proudly released NowJS v0.7. This version is the most stable and performant version of NowJS to date. It's managed to survive our vicious benchmarking tools and our ridiculously comprehensive test cases. But our greatest accomplishment with this release is that every single line of code is brand new.

In a matter of minutes, we decided to scrap 3 months of work and rewrite our architecture. No file, function or concept was left unquestioned. What inspired this iconoclastic frenzy? Here's why we threw out all our code:

1. Optimizing for real-world usage

When we started working on NowJS, we knew what we wanted the software to do. But there was no way of telling how people would use it and how it would perform in these scenarios. With v0.7, we optimized and made tradeoffs based on the data we collected from real-world usage.  It turns out that the vast majority of usage was for RPC and the occasional syncing of very simple variables. We reduced code complexity by not worrying too much about syncing complex nested/circular structures, and optimized the remote procedure calls process to be as close to constant time as possible.

2. Perfect opportunity to future-proof

Over time, we became much better at anticipating the type of features we were going to add to the library. This meant that we weren't shoehorning functionality onto a codebase that was never designed for it in the first place.  No longer were we wrestling with absurdly complex data structures and the equivalently insane functions needed to manipulate them. We eliminated the need for cryptic utility functions like "mapAndMergeFunctionsInScopesHelper". After the complete rewrite, features that we indefinitely put off took mere minutes to implement. 

3. Sunk costs and egos get in the way of good software

Our job as developers is to provide the best library so that you can write high-performance realtime web applications easily. We could have defended our code just because we worked hard on it for months. But accepting the large upfront cost of a rewrite meant that we would save on development time in the future and also provide a better product to our users.

So take a good look at your own codebase. Does it frustrate you when you try to add new features? Are you smarter now than when you first wrote it? If so, then perhaps it's time to dump it.

P.S. Check out NowJS v0.7 . It's rock solid and super-optimized for the best real-time RPC experience.