9 ms·
A reminder that Joel Spolky's essay being cited is about people rewriting ugly code that already works. That nuance is important because successful companies d
by jasode 7y ago
A reminder that Joel Spolky's essay being cited is about people rewriting ugly code that already works.
That nuance is important because successful companies do invest in rewrites when there's an architecture change because it's the cleanest most economical way to do it. My previous comment of Microsoft examples: https://news.ycombinator.com/item?id=19245653 https://news.ycombinator.com/item?id=19245653
Another example is Google rewriting their early web crawlers of Python/Java into C++ to make them more efficiently scalable to thousands of machines. They also rewrote the frontend web server from C++ to Java.
But some rewrites also failed such as Evernote's rewrite to C#/WPF.
I think for the topic of "rewrites bad/good", it's better to list a bunch of famous real-world case studies and extract the common criteria that makes rewrites successful.
- zaphar 7y agoI was around for the Google Webserver rewrite and it was actually a rewrite done by refactoring not clean slate. It's amazing what you can do with disciplined refactoring, even moving to a new language.
- BurningFrog 7y agoIf you have a decent test suite to lean on, you can work miracles this way!
- wpietri 7y agoAnd if you don't have a decent test suite, you might as well build one. So much of a rewrite is archaeology, figuring out what elements of a system are intentional versus accidental. A great way to do that archaeology is to start weaving a net of tests around the existing system. Sort of like Fowler's Strangler Fig pattern: https://martinfowler.com/bliki/StranglerFigApplication.html https://martinfowler.com/bliki/StranglerFigApplication.html
- majormajor 7y agoYeah, if you don't have a detailed test suite, and can't build one, you probably don't fully understand your requirements, and your rewrite is in trouble already.
- AstralStorm 7y agoMind you, maintenance is in trouble too. Just a different kind of trouble. If you have original code, you can always write a test suite based on it, unless management is averse to this. (Begging the question why they're not averse to a rewrite.) Like any test suite it is not going to be complete. Ultimately it's best not to get piled on by rewriting really and often in small parts. (Carmack way.)
- pseudoramble 7y agoThis sounds really interesting to read about, especially refactoring into an entirely new language. Are there any articles about what that process looked like for Google at the time? Or any example that changed languages really.
- dpwm 7y agoNot the OP, and no experience with google, but I have personally worked in a way that sounds as if it could be similar: First, you start with a slow but correct prototype in python. This can then be refactored into python closer to C, thinking about the data structures and functions that will be needed in C. Then, you can refactor these bits into C. I've usually done this one module at a time. You then write python bindings to this new C code. There are a number of shortcuts available here with differing tradeoffs, but you can just use the Python/C API. In the end you're left with a C library, some bindings, and some python that just calls to the python bindings for the C library. It would not be a huge leap to go from that to a full C implementation. Nothing I've said here is C specific, so you can do the same with C++. There are upsides and downsides to this whole approach. For me, one of the downsides is the amount of stuff to remember, especially some of the quirks of extending Python. I find it easier to start with something correct but high-level in Python and work down to something easier to translate into C, even if I skip straight to the writing in C bit. I have found this usually leads to a significantly better design whilst it was still Python. You can also test the behaviour of the C and python modules against each other.
- pjmlp 7y agoIncluding the monetary outcome of the re-write. How much was the cost of the rewrite (total hours expended) and what was the benefit (energy savings, less hours spent bug fixing, less customer support calls, ...).
- eskimobloood 7y agoHere is a nice write up on different examples that either work or fail: https://medium.com/@herbcaudill/lessons-from-6-software-rewrite-stories-635e4c8f7c22 https://medium.com/@herbcaudill/lessons-from-6-software-rewr...
- commandlinefan 7y agoA few years ago, I worked on a rewrite of a system that had been implemented in ColdFusion (yes, a few years ago - well into the 21st century). I can't imagine even Spolsky arguing that it shouldn't have been rewritten at that point.
- exdsq 7y agoColdFusion URL traversals were the first servers I cracked as part of the OSCP course. They seemed to be pretty horrible! A rewrite definitely sounds appropriate. I think we should consider developer Morale when it comes to legacy systems - it’s hard to hire and a lot of people want to leave if they’re stuck with them.
- nobleach 7y agoOne of my favorite pieces of trivial knowledge is that MySpace's rewrite to asp.net included mimicking all their old ColdFusion .cfm routes.
- magduf 7y ago>I think we should consider developer Morale when it comes to legacy systems - it’s hard to hire and a lot of people want to leave if they’re stuck with them. Basically. Some systems/languages just don't have many people on the market with expertise in those things, and you may not be able to hire someone who does, and get them to relocate to where you are. If you try to stick someone else with that job, they're not going to want that on their resume, so they'll just look for a new job that does fit their career goals. For instance, personally, I have no desire to work on VB.NET code at all, so if my company suddenly decided to make me a full-time VB.NET developer (including training etc.), and wouldn't take no for an answer, I'd immediately look for a new job. Having VB.NET on my resume isn't much better than having a job gap.
- regularfry 7y agoEven with rewrites, there are good rewrites and bad rewrites. For my money, big-bang rewrites are bad. If you can strangle out the old system as functionality is gradually moved across into the new one, that can work, but still relies on actually finishing the transition so the old system goes away. What was yours like?
- hn_throwaway_99 7y agoI think the ironic thing about Spolsky's example is that, in the end, it worked. It eventually gave birth to Firefox. So I think there are many lessons to be learned about how to do a rewrite, how to message it, how to do it in a way that it doesn't stop other forward progress. But if a rewrite fails, that doesn't necessarily mean that not doing a rewrite would have been any more successful in the end, and that's the trap I think people fall into.
- regularfry 7y agoDoing the rewrite definitely tanked the company. That's a fairly low bar that "not doing a rewrite" has to get over to be a better option.
- paulryanrogers 7y agoMicrosoft giving away IE for free probably had more to do with Netacape's downfall than the rewrite alone.
- regularfry 7y agoBeing unable to respond won't have helped.
- goto11 7y agoHow many people actually paid for the Netscape browser in the first place? Was selling the browser ever a viable business model? Netscape could have developed different ways of getting money, like ads on the start page or default search engine. But such schemes could only have worked if they had retained a large market share, which they jeopardized with the rewrite.
- hinkley 7y agoI was always a little irritated to see a boxed copy of Netscape in stores, but it did solve the 'how do I get my initial web browser?' problem for people who had no idea what "FTP" is. So I'd say that for the majority of people (the 90% who were not tech people), they bought it once. Once they got later in the adoption cycle that would have dropped off, and the moment IE shipped that would immediately trend to zero. Netscape was free because Mosaic was free, and Mosaic was free because of the National Science Foundation. (As for getting your initial browser, IIRC you could send away for copy of Mosaic on 2 floppies for the cost of shipping and media, but that could take weeks)
- artsyca 7y agoAll writing is rewriting and all factoring is refactoring it's a question more of how it's actually done i.e. in-situ or in parallel and of course there's no technique that's good or bad per se how many times have we all heard "Never rebase!!" that's just a crock
- rsynnott 7y agoWasn't Evernote's (successful) rewrite _from_ C#?