Go Ahead, Do The Big Rewrite

Many experienced developers caution against the Big Rewrite. Perhaps the most famous of these is Joel’s adamant proclamation that the Mozilla team’s decision to rework Netscape from the ground up was “the single worst mistake” that a software team could make.

Although I agree with Chad’s arguments and to a lesser degree with Joel’s, I can’t help but to notice: what Joel called a huge mistake turned into Firefox, which is the best thing that ever happened to the web, maybe even the best thing that’s ever happened to software in general. Some “mistake.”

Ok, ok. So most of the time the big rewrite is a bad idea. Mozilla got lucky, or tried really hard, or it doesn’t count if you’re an open source project, or something.

Except that I’ve done several big rewrites of commercial applications in my software career, and every time it has gone very smoothly. In all cases the end users have been pleased, and I and the other developers find ourselves saying “We should have done this ages ago!”

In fact, Bitscribe is currently finishing up one of these right now. The application being rewritten is one of those sprawling enterprise apps with countless nooks and crannies of functionality. Written in a blend of PHP, Perl, PL/PGSQL stored procedures, and C++ (GTK 1.0, baby!), it dates back to right around the turn of the milenium. So not utterly ancient, but plenty has changed in the software world since then. The rewritten application is 100% Rails.

Everyone involved with the project just couldn’t be more pleased, from what I’ve seen. It’s been a lot of hard work, sure, but the benefits are massive. Developers are energized and excited to be working with the latest tools, and throwing out years of accumulated developer debt. (The legacy app had been maintained by a variety of different companies over the years, so you can imagine what the code looked like.) The client’s staff is loving the shiny ajaxified interfaces. And the client’s management (you know, the people who sign the checks) are seeing a whole new world of software unfold before them, and seem very aware of the efficiency improvements that will come with it.

There was a benefit that we didn’t anticipate, and it’s turned out to be one of the most useful. In the process of rewriting we’re not just porting code; we’re rethinking the design. The technical design of course, but also application design. It turns out that the wisdom the clients had gained from years of production use of the legacy application pointed to many insights on a streamlined design. We’re able to provide the majority of the functionality of the original app with a fraction of the complexity.

And not just code complexity, but user interface complexity. When all is said and done, the client’s training costs for new staff will be greatly reduced; there’s much less likelihood of entry error; and the application matches their business process more closely. Et cetera.

So I’ve never had a rewrite go badly. But maybe that’s because I’m inherently cautious and skeptical about rewrites. I lean toward waiting a bit too long, rather than doing it a bit too soon. So then by the time we go to do it, it’s really overdue.

Raganwald says “And you’ll need to be 100% sure your team has the horsepower to get the job done and is going to use a process that can handle the load.” Maybe that’s why it’s gone well for us; Bitscribe has massive developer horsepower, and massive focus on process. And even for us, there’s been lots of strain on the team doing the rewrite.

I’ll admit that there’s a unique kind of pressure that you get in this situation. It’s not like the ordinary pressure to meet software deadlines. I think it’s that sense that you can’t turn back. You don’t want to fix bugs or add features to the legacy code, but the client needs those changes so that they can do business. So then you have to press on ahead and try to get the new version workable as quickly as you can. And as Chad points out in his essay, there are seemingly endless little bits of functionality in the original app that need to be provided in the new system. It’s not a kind of pressure I’d be willing to bear most of the time, but it can be worth it when an app is really due for a bottom-up overhaul.

And let’s face it, you’ve gotta rewrite sometime - no software system can run forever, and the cost of running even a marginally outdated app can be tremendous. I guess the trick is just picking the right time to do it - and then having a healthy fear of just how big a job it really is. The moment you think it’s going to be easy, that’s the moment you’re digging your own grave. Be scared of what you’re facing and you may just have a chance.

9 Responses to “Go Ahead, Do The Big Rewrite”

  1. Peter Harkins Says:

    From Joel’s business perspective, the Mozilla rewrite was indeed a failure: Netscape lots its market share and got absorbed by AOL. The project was eventually a technical success, but Joel’s point is that technical decisions are business decisions.

  2. Zach Baker Says:

    Joel rejects rewrites as a strategic mistake for a company, not so much a technical mistake, so I don’t think Firefox is exactly a counterexample. But I like your perspective on “big rewrites”. I thought of a practical rewrite suggestion from my experience so I wrote it up on my weblog:

    http://www.zachbaker.com/articles/2007/01/11/rewriting-software-from-scratch

  3. adam Says:

    Peter: Right you are. Of course Netscape was already a business failure - they made their browser code open source as a sort of last-gasp, desperation move. Which actually worked for wounding their enemy, but didn’t do a thing for making them any dough. So this should definitely not be considered a guide for business rewrites. (Or maybe it should. It took ~3 years to have a working browser again, so just try telling the management “I hope you don’t mind if you don’t have any software for the next three years while we work on this”)

    Zach: Excellent follow-up. “Only rewrite if you will be able to make significant design improvements based on understanding gained from the previous version” seems like about a simple a rule of thumb as one is likely to get on this subject.

  4. mark Says:

    “Although I agree with Chad’s arguments and to a lesser degree with Joel’s, I can’t help but to notice: what Joel called a huge mistake turned into Firefox,”

    From this sentance I can’t tell if you have your history right. Netscape rewrote navigator when IE was coming on strong. That was a disaster. Eventual the nvaigator codebase gave rise to seamonkey and firefox, after the war was lost.

  5. rchf Says:

    Mark - “Eventual [sic] the nvaigator codebase gave rise to seamonkey and firefox, after the war was lost.”

    Every war ‘won’ can become tomorrow’s battle ‘lost’. Better to compromise. Unfortunately, Microsoft doesn’t compromise so eventually it will lose. Firefox, Open Doc, OpenID, the lost battles for Micrsoft are becoming more frequent.

  6. SuezanneC Baskerville Says:

    Surely there must be examples of new software products successfully competing with perhaps outdoing existing legacy applications. Wouldn’t the new successful competition have had to do the equivalent of a complete rewrite?

  7. SuezanneC Baskerville Says:

    Given the existence of company A with a successful product, why would it be possible for company B to produce a successful competitor from scratch but impossible for company A to produce a successful new version from scratch?

  8. Nikhil Bach Says:

    This one makes sence “One’s first step in wisdom is to kuesstion everything - and one’s last is to come to terms with everything.”

  9. The Big Rewrite - Other articles | Lazycoder Says:

    […] Adam Wiggins: Go Ahead, do the big Rewrite […]