Why We Threw out All Our Code (And Why You Should Too)
blog.nowjs.com
blog.nowjs.com
It's stupid to argue, "You should never tear down a building" (like http://www.joelonsoftware.com/articles/fog0000000069.html implies) and it's also kinda stupid to write an article entitled, "Why We Tore Down Our Building (And Why You Should Too)"
Neither is universally right. The right thing to do in a given situation is a difficult and complicated question to answer, and it depends on the building in question: how big it is, how well it was designed, how well it's been maintained, etc.
In this case it was 3 months worth of code. I think the analogy is closer to "we tore down this clay hut we built". Easy to build, easy to tear down.
If this were a mature code base, I would be a little more shocked.
Your analogy fails, sir.
It's easier and more common to write dirty code that functions as it should than build a building with poor foundation but that looks and functions as it should.
You could tear it down and build a fancy new one that would cash flow even more with higher rents and lower costs. It's exactly what the market needs today. Green energy, nice, open spaces, new paint. Do you break out the bulldozers?
It depends, of course.
This is one of the most amazing things about rapidly growing cities in most of the world. Neighborhoods that start out as informal shanty-towns full of lean-tos with leaky roofs become, over the course of years, first neighborhoods with modest but permanent cement block buildings and tin roofs, and sprout all the typical urban amenities like power lines and sewers (often at first pirated ad-hoc from other nearby neighborhoods), have their roads paved, etc., and a few decades later look like normal neighborhoods, sometimes even surprisingly gentrified ones.
The question is: which is the more appropriate metaphor for a project? A building or a city?
I disagree with the OP that deciding to recode can simply be compared to tearing down and making a new building for no reason. That's oversimplification.
First, there are times when buildings must be demolished and built from scratch. The OP makes this idea seem ridiculous but it happens everyday when buildings are in fact demolished and rightly so. Second, fewer buildings are demolished and built from scratch relative to programming projects demolished and built from scratch due to the inherent differences between a coding project and a building project. For one, the former is more regulated and carries more physical risk than the latter(a coding project).
Maybe some projects are more building innovation centres, that later go on to be used within actual buildings, and some don't get used.
http://www.vt.edu/about/buildings/surge_space_building.html
"The building provides space to temporarily house academic or administrative units that are displaced because of renovations to their home buildings. The facility was designed using a pre-engineered steel frame with its exterior clad in metal panels and precast concrete-like panel accents. The building is designed to be disassembled and recycled in 10 or 15 years.
One floor; 45,000 square feet. Find a public access defibrillator in the hall intersect."
Unlike software, new buildings are almost invariably significantly more efficient and less resource intensive than old ones - and green building has, of course, gone from a fringe movement in the wake of the Rio Summit, to the mainstream and is now standard for public and corporate buildings.
Like poorly written software old buildings are expensive to operate and maintain (and unlike well written software buildings still deteriorate over time when left only to their own devices). Finally, like software one must go through old buildings and figure how systems were designed and installed and patched in order to modify them - and this is very time consuming. Per square foot costs of renovation are commonly as much or more than new construction.
I know that startups do way more that just write code, so I'm not criticizing them at all. And it seems they're not afflicted with the typical engineer modesty when it comes to their own codebase, which is a good thing. On the other hand it's not exactly a superhuman hacking achievement to rewrite this from scratch.
When you throw out your code you're throwing out all that knowledge on the assumption that you can build it all back with improvements.
Evolving an application from a known good state to a known better state is usually the best approach unless your codebase is small or your app has no traction.
Rewriting your app from the ground up is like getting divorced and dating a new girlfriend. The first few months are a lot of fun until you figure out how much you lost.
Netscape 6, or at least the mere fact that it existed and worked well enough and the fact that it was the first browser ever that did standards well and focused on not much else other than standards, made it the most important browser ever created.
Netscape 6 was the most revolutionary browser project ever created and had the development effort behind Netscape 6 not been done, we would possibly have had a much worse very IE-only web today.
Never mind that beyond all that, Netscape 4 was terrible and deserved to be thrown out.
I dont disagree with the general sentiment of your comment. But as someone who attempted to use Netscape 6 at various stages of its development, I fear that statement might be stretching facts a little bit.
The reason some code bases can’t be rewritten after a few years is because when the code was only three months old, the team passed on the chance to rewrite it while it was still a tractable exercise.
But most programmers I know don't need any encouragement to rewrite stuff, myself included!
1. Do I have sufficient tests and testing to do this without breaking things?
2. Do I want to want to rewrite because I cant be bothered understanding it?
3. Is there going to be any gain now or in the near future by rewriting it?
4. Will I be able to rewrite it sometime in the future as part of another piece of work which actually delivers value?
Unless I come up with Yes, No, Yes, No I tend to leave it alone. There are other things of value I can do with my time.
EDIT - Formatting...
Egos are what drive people to throw away their entire codebase and start over.
Sometimes ego is involved, but sometimes rewriting is just the rational thing to do from a cost/benefit standpoint.
It's so much easier to write from scratch than it is to refactor. So many programmers have no idea how to tackle an existing codebase, even if it's one they've wrote themselves.
As perfect as your code might be, customers deserve a hint when major changes were done under the hood. Moving from 0.6 to 0.7 screams "just a few changes, some new features", not "we threw everything out and started over". This should have been made into "1.0beta", I would think.
Edit: for perspective, a thoughtful proposition on how to approach software versioning: http://semver.org
My codebase is 10s of thousands of lines, it evolves as I get better but I'm not going to scrap it.
Netscape 6.0 was a complete rewrite. The article claims that this was a mistake.
Now, if you would recall, one of the reasons Netscape 6.0 was completely rewritten was to use Raptor/NGLayout. Raptor/NGLayout was later renamed to Gecko. Gecko is the currently developed Firefox rendering engine, and Netscape 6.0 marked the start of the Mozilla foundation.
I would harshly argue that Gecko would not have taken off nearly as well without Netscape's rewrite. But this is definitely not a story about Gecko's popularity. It's about the reason why Gecko was the decision they took at the time, and the current impact of Gecko.
Besides the fact that Gecko was one of the early open-source success stories, the reason why Netscape decided to scrap everything and start from scratch was simple: Netscape 4.0 was horrid. Remember back to the days of IE vs Netscape. Netscape was significantly slower, and had no dynamic HTML among many other features. It was buggy and would crash frequently. And the development on the "continuation" of 4.0 code was simply too slow to compete, because of outdated, not modulated code, and stuff stuck in that simply "worked," and never changed to allow for future changes.
Now, people attribute Netscape 6 to Netscape's death because of this radical decision. But take a look at Netscape's usage statistics: http://upload.wikimedia.org/wikipedia/en/1/16/Netscape_Navig... . Hey, guess when Netscape 4.0 came out and IE started to dominate? 1996-1997. By 2000, when Netscape 6 was released, Netscape's usage already dwindled down to nothing.
Now, you're thinking, why didn't Gecko save Netscape? It takes too long to reverse these tides. Netscape was already dead. AOL acquired Netscape in 1998, to combat IE. Then, in 2003, AOL won an antitrust suit against Microsoft, and allowed AOL to use IE royalty-free. Netscape was pretty much scrapped at that moment because the damage had been done.
But wait.
Mozilla released Phoenix in 2004, based on Gecko. You should now the story from there. (Clue: Phoenix -> Firefox)
Disclaimer: I'm not saying that Firefox > IE or Chrome or whatever. I'm saying that the codebase Netscape 4.0 was based on was doomed to fail. Gecko still lives on today, and was started as a rewrite of Netscape.
Anyway, my point is, there are times to rewrite things, and there are times to keep them the same. If you have a good, legitimate reason to rewrite, as Netscape or NowJS did, you should. If you are just the stubborn programmer that always implements his own Queue or QuickSort when libraries exist, don't.
This is one of the reasons you should write tests as you develop - it ensures you have a consistent baseline you can apply.
As a developer you are constantly learning & evolving. If you're not confident enough to draw a line under what you've done, step back and evaluate your position and rewrite it when needed - that's fine, but others find it an effective approach to building something bigger, better and more sustainable.
I've been thinking about this because I'm writing an application in Rails and realized relatively recently that it would be better suited as a Node application. My motivation for using Rails was that it was what I knew the best. Luckily for me, the most time-consuming part was the front-end, not the Rails part, so I'm hoping my switch to Node will be relatively painless.
As bad as Netscape 4/5 may have been, while I can't guarantee trying to refactor instead of rewrite would have gone better, I can guarantee it couldn't have had any worse a result than the Total Death that was the actual result.
And the phoenix-return of Mozilla is the exception, not the rule.
Even though ths external case is stronger, this holds true even from the company's perspective. AOL continued to release Gecko-derived browsers through 2007. They got something from that (even if it was just AIM installs and propping up the fading Netscape brand for other purposes).
Compared to earlier versions it was incredibly slow—even by the standards of the time—and crashed a bit more frequently. It took much longer to load or perform some common tasks. Sure, the rendering engine was better for many pages, but browser sniffers were still common, and (like now) weren't updated often enough, so bad versions of sites got served occasionally too.
There were a host of reasons why Netscape 6 was bad from a user's perspective. Spolsky has it right when he says Netscape 6 was a piece of junk. Let's not allow time passing to permit us to remember it more fondly.
Sure, future versions got better, but that was due to he creation of a new "corporate" memory. It took a while to get over having discarded so much learning.
Also, the money quote: "It's managed to survive our vicious benchmarking tools and our ridiculously comprehensive test cases. " My assumption is they are using the same languages and tool sets (not porting from language X to Y).
I'm curious as to how long the rewrite took though.
I've often been faced with a situation warranting a rewrite, but I never mustered the courage to actually go with a full rewrite I don't think. Gradual rewrites are much more my thing.
So my 'rewrites' sometimes come in the form of superficial organisation. Looks moderately nicer, doesn't work any better.
I guess it is courage though. You don't really know that your rewrite will be an actual improvement, or if you'll even pull it off. Brave move indeed.
I guess they did not rewrite those from scratch. If so, I would guess they only rewrote, at the most, 25% of their code.
Chances are if you wrote properly modularized code, you can rewrite modules one by one, which is perfectly legit. But just dropping everything and trying to rewrite a product from scratch is a mistake that a company usually only makes once (before they die).
Refactoring is almost always preferable to throwing out all your code, imho.
Maybe it is better. Maybe it is more stable, smaller, and faster, and well-tested. But it hasn't had as much "real world" use thrown at it as the previous codebase had.
I'm not saying I won't upgrade, but I'll likely wait a bit until I do and stay with what I know works right now, at least in production.
"This is grandpa's mattock; my father replaced the handle and I replaced the blade".
But if its just an amoeba and you have a lot of time, go for it.
Anyway, congrats on 0.7 Sri!