I have participated in a few (small) rewrites that were successful, and this would be my advice: Don't rewrite an entire project at once. Pick off smaller features first, get a feel for what your new approach will be like before you commit to the big stuff. This will often mean you have to migrate from a monolithic architecture to a services architecture first. This means your project will grow in complexity first. If you're confused about why a project first grows in complexity before shrinking, watch "All the little things" by Sandi Metz, it's the greatest programming talk ever recorded. If your rewrite gets stuck after adding all of that complexity, then you've played yourself. Worst thing that can happen is you rewrite your entire project, some users or customers start using the new project, but you've failed to rewrite everything and some chunk of your users are still using the old codebase. Now you've got twice as much code to maintain.
Before you start a rewrite, consider refactoring and rearchitecting the old codebase, there might be a gem in there that just needs some love and attention.
That said there definitely are famous successful rewrites, and I think web application backends are especially suitable for rewrites. Most famous are Twitter and LinkedIn, Twitter going from a relational database backend to a more appropriate fan out message queue based backend allowing them to scale beyond imagination. LinkedIn going from a big rails monolith to super fast node.js microservices reducing their hardware costs a hundred fold if stories are to be believed.
For a program that took 10 years to develop, a rewrite will probably take around 10 years as well to reach feature parity. Obviously, if you stop development on your successful app for 10 years waiting for the rewrite, you will fail. If you think 10 years worth of work can now be finished in 2 years with the benefit of hindsight, you will fail.
But, if you start your new app by first attacking new markets that the old one couldn't, so that the new app is genuinely valuable in itself, and then you slowly consolidate it by adding features that the old app had, while still maintaining a crew developing the old app as needed to address the existing markets, you can justify the investment and then some. Of course, this should only be done if it has become clear that the old program is really not possible/worth it to extend and continue in the long run, which can happen for various reasons.
There will be times where you will find massive shortcuts you can take, since odds are things you had to develop from scratch 10 years ago exist pre-packaged today. You may also be able to re-use parts of the old app that were actually in good shape and take them whole. But you should never rely on these things making your work shorter - they are nice boons, but the correct estimate is still in the order of magnitude of the old app.
Necessary rewrites happen because they did too much YAGNI thinking in version 1.
However, "X2" was definitely an example of an appropriate rewrite. It had the following conditions:
* The existing code "X" was the product of an early-phase startup which hadn't yet figured out what it was going to do. "X" already existed at the point we were still asking questions like, "Who is the customer?" with possible answers like "The NSA and similar entities" even though it eventually became a consumer product - and so obviously it was very flexible but had also been greatly distorted from its original conception to produce a product we were actively selling.
* The existing code was developed and maintained by a third party team. So the knowledge of how that system worked was something we'd need to absorb anyway to bring it in-house. Existing code reflected house style of that team, and X2 would be in our style.
* It was modestly sized. I think our plan said our small team (less than half-a-dozen people, not all of them available for this full-time) would rewrite it in one calendar year, with an MVP in maybe six months and from there simultaneously copying less important features from "X" and also new want-to-have features to get the finished "X2", that's roughly the timeline we followed.
* I was pretty confident we could execute from the initial description of the work to be attempted. I went into a meeting assuming (as I always do in all-hands meetings) that I'd get fired, and came out thinking I should brush up my Java (the chosen language for "X2") but it seemed very possible.
* The non-technical leadership actually wanted a new system. "We need a new pig" is how it was explained back to me by the CEO. (From "Lipstick on a pig" the idea that superficial changes to a product can't really disguise its flaws) so there was buy-in of this idea and nobody yelling at us about why the "X2" MVP doesn't deliver most of the things "X" didn't have yet.
[This software, and its predecessor, had code names but somebody let me name the successor software and I have no imagination so although it wasn't literally "X" and "X2" that's about how similar the code names were].
The reality of rewrites is that they're often blamed for all of that, while the issue is not the rewrite. The issue is that companies that write bad software will, if given an occasion, write bad software again.
The issue with rewrites is actually that they're not large enough in scope. When you rewrite software, you should probably also rewrite contributors' interactions, the way the company handles power dynamics and, occasionally, the way accounting works at that company. Short of systemic changes, rewrites are likely to fail. But again, the company is also likely to fail other initiatives aswell.
Rewrites that fail in an isolated way are few and far between.
> Before you start a rewrite, consider refactoring and rearchitecting the old codebase, there might be a gem in there that just needs some love and attention.
OR it might be a dumpster fire that drives your engineers away, one that is fueled by unreasonable deadlines and expectations. Also good luck refactoring your codebase at snail's pace with noncomitting approval, on your own unpaid overtime.
Pretty sure the article is tongue-in-cheek satire.
> There's no real advice about rewrites in this article.
The actual advice is in the top image which goes:
- Todo: Add critical customer request, fix bugs, new features
- In progress: Rewrite everything
Citation needed.
All of these is based on random internet wisdom (e.g. Joel's condemnation, based on a different era, different delivery model, and different concerns than most of today's startup and enteprrise code), and anecdotal evidence.
Well, talking of anecdotal evidence I've seen lots of succesful rewrites, that made the thing faster and better.
Heck, most/all of the FAANG stacks are rewrites. Twitter, for example, as you've mentioned yourself, is not the same program that needed restart every day to avoid a memory leak back in the 00s - they rewrote it. Reddit is not the original Lisp, and so on.
It's also about the scope. You immediately undestood "let's rewrite the whole company code" and advise "don't rewrite the whole project". Well, who said it's "a" project to begin with?
Companies more often than not have tons of different services, and rewrites can be easily done for such isolated services (e.g. like the dl.google.com rewrite into Go).
Tons of core services of YouTube, CloudFlare, Google, Facebook, and tons of others have been rewriten with languages as Go, Rust, Hack, etc. and they have written about the experience and results as a success. And it's not like survivor bias, e.g. the keep mum about failed cases, because we hear about failures all the time (just not concerning rewritings).
I can't think of any big public disastrous rewrites except for maybe frontend ones like Digg or enterprise modernizations for example when the government wanted to get rid of their 60s mainframes and the effort cost billions and was ultimately unsuccessful.
However, I have had success in rewriting my own code base a number of times. This is a unique situation of a one-man-band that understands the business case, handles support, and every bit that went into every decision of the code base.
With this kind of clarity, when you've spent years with the problem domain, you can uniquely rewrite a project to get at the real business case that, now with years of experience, you see what your customers actually wanted you to solve in the first place, or maybe what they evolved to want in the end.
Jim Keller advocates rewrites in a similar way as the only way to progress in chip design.
I think we could rewrite very basic things in exciting ways with this sort of attitude. For instance, we know a lot more about what we need in a desktop OS, an email client, a search engine, etc. Basic things that have gotten a lot of cruft over the years as they evolved. Taking a fresh look could be rewarding.
I guess one could reframe this as 'first principals thinking" but with the caveat that the problem needs to be truly understood.
Here's Jim Keller talking about it: https://www.youtube.com/watch?v=Nb2tebYAaOA&t=1361s
I write a lot of python, and the irony of this comment is that it’s probably true.
Worth the cost and time and effort? /shrug
Easier and faster to keep implementing features in? /shrug
…but out and out faster to build, deploy and run?
Yep, probably.
Im my experience python applications are slow it’s usually because your user logic is heavily implemented in python, and despite alllll the hand waving, that is, in general still slow. The package manger is slow and broken. It’s painful to deploy.
You can probably solve the problem in other ways, by picking parts to move to another language that provides an easy way to expose python bindings… but you know.
Make it faster by rewriting in go will probably work, if you only goal is “runs faster”.
The world we live now in. It's not funny anymore.
The shocker.
(That said, yes, motivating developers is a thorny problem.)
Developers always come with their own perverse incentive. They like the new, the clever, the smart, and the simple, and rarely appreciate the battle tested and extensible.
The author seems to be generally pro rewrite in his article so I can't tell if this is sarcasm here.
- The application was complicated, - The application was written in Ruby, and he didn't like Ruby. - Golang was way cooler.
Fortunately our director pointed out that there was no customer value to a rewrite, so the idea was shelved.
https://www.joelonsoftware.com/2000/04/06/things-you-should-...
Usually you cannot count on competitors to stop all developmet for half a decade while you rewrite.
Checking Wikipedia, the IE5 timeframe was them reaching their peak before stalling on the infamous IE6, and Firefox (sort of a rewrite of the rewrite) starting to make some small headway as they let IE stagnate.
https://upload.wikimedia.org/wikipedia/commons/thumb/2/24/Br...
look up "wasabi"
https://www.joelonsoftware.com/2000/04/06/things-you-should-...
Very good post, that holds a lot of experience. Unfortunately these things have to blow up in your own face, often more than once, for a lesson learned.
> It’s a bit smarmy of me to criticize them for waiting so long between releases. They didn’t do it on purpose, now, did they?
Well, yes. They did. They did it by making the single worst strategic mistake that any software company can make:
They decided to rewrite the code from scratch.
Every release includes new things and rewritten things. If we add new on old, we grow technical debt; if we rewrite too much, fixes and features are delayed too long.
It’s a tough balance. Our code and issues are full of comments re how things should be done, with cross references we added as we figured out what things need to change together.
As Joel Spolsky notes in the twice-linked post, reading code is harder than writing.
Just today I eliminated hundreds of lines of code after writing maybe two dozen over the last few days.
The writing and deletion took no time at all. The reading and forensic mental compilation and execution took days and days.
That’s our golden rule: change nothing you do not completely understand - and you only really understand it if you can explain it in plain English to someone who doesn’t know the code.
The coolest thing is that as we go along doing cool things becomes easier and doing wicked cool things becomes possible.
Just this morning we had to force ourselves to remember that entire blocks of code with poor reporting of errors are as they are because until changes we made elsewhere just weeks ago, there was no point in doing better: the better reports had no place to go.
But after a major refactor initiated primarily to make maintenance and addition easier, we can now do things with dramatic - and wholly positive - UI/UX impacts that were simply impossible before.
Read read read read digest digest cogitate muse read read correct read confirm, explain, write.
Nowadays, people are usually too afraid to even talk about it. As a result, many things that could be straightforwardly solved by rewrites were delayed to the point virtually impossible, causing eternal suffering and valuable features blocked forever.
Perform a root cause analysis for why the current code is in a bad state and why it doesn’t improve over time.
Nobody rewrites anything in the same stack/technology.
> Someone is likely to point out all the problems your rewrite will bring. You’ll find it much easier to convince people if you’ve already throught these through, and you bring them to the conversation yourself.
I wish more people did this!
What? Think critically? Me too.
The first implementation you write is and will always be a (throw away) prototype.
You learn a lot. You understand much more of the spec. Maybe users got a go. Maybe its just internal.
Now your write the first version. It is better. You understand even more.
Writing a proper prototype first used to be a thing. As we all know once a prototype was getting close to finished the budget changed and bam your prototype is in production.
It is not all that practical with huge applications. Perhaps there is a lesson in that.
1) Document exactly what the existing thing does.
2) Write high-level tests for this functionality.
3) Make sure there are no features that will need to be added to it. Make sure everyone is onboard with not adding new features to it. Make sure people understand that adding features to an in-progress rewrite jeopardizes the entire thing.
4) Rewrite it in the original language, reusing those high-level tests you wrote in step 2.
5) Let people know that they can add features again.
It's a lot less glamorous than just starting afresh which is where things often go wrong.
Here's a recent podcast transcript with the author looking back on the book:
https://www.infoq.com/podcasts/working-effectively-legacy-co...