Live data from Hacker News

Things You Should Never Do, Part I (2000)

joelonsoftware.com

21–30 of 104 posts

Re: Things You Should Never Do, Part I (2000)

#21
post #4

Related: Things You Should Never Do, Part I - https://news.ycombinator.com/item?id=31122975 - April 2022 (7 comments) It’s harder to read code than to write it - https://news.ycombinator.com/item?id=31117277 - April 2022 (2 comments) Things You Should Never Do (2000) - https://news.ycombinator.com/item?id=23725867 - July 2020 (83 comments) Things You Should Never Do, Part I (2000) - https://news.ycombinator.com/item?…

And a bit earlier:

https://news.ycombinator.com/item?id=6327021 - Sept 2013 (154 comments)

Re: Things You Should Never Do, Part I (2000)

#22
post #13
post #10

Earlier quoted context omitted.

50-100K LOC are less than the amount of code for the build system in a couple of projects I worked on.

Then you've got bigger problems

It turns out a lot of people have a lot of problems bigger than yours.

Re: Things You Should Never Do, Part I (2000)

#24
Something I've found useful for avoiding the ever-present urge to rewrite things: build software with comprehensive documentation and automated tests.

In my experience, the main reason a rewrite feels like a good idea is that the existing software has grown into what feels like an unmaintainable mess: changing the software in any way at all is so painful that it feels like you'd be better off starting from scratch.

Done right, automated tests dramatically reduce the cost of changing software. You can make a change and feel confident that you've not broken anything outside of the area that you're working on because the (mostly integration) test suite continues to pass.

Likewise, documentation. Without good, comprehensive documentation you quickly find that there are all sorts of areas of the project that you don't understand - which can also make a rewrite feel like it could be justified.

The catch there is that you have to _trust_ your documentation. If you (or your team) know it to be out-of-date you'll lose trust in it - so you have to get to a point where the documentation is thorough and any mistakes in it are treated as high priority bugs to be fixed.

But... if you can get both of these things in order - your automated testing strategy and your documentation process - my hunch is that rewrites will be FAR less tempting.

Re: Things You Should Never Do, Part I (2000)

#26
The main reason why developers do rewrites is because it is easier to read your own code than it is to read somebody else's code. Doing a rewrite means you only have to work with code that was written by your current coworkers or by yourself.

This is also the core motivation behind all of the schemes to force a single coding style on all developers at the cost of performance and usually with an extremely complicated design for seemingly no reason. Usually, these turn out to be unreadable messes as well a generation later once everybody has moved onto the latest and "greatest" coding style trend.

Instead of doing rewrites, you can just refactor code. That means, among other things, deleting obsolete code for platforms you no longer support and, in the case of C/C++, converting macros to functions. You can also document the codebase (with comments not commit messages) so that developers understand what the code does and why it is there. But a full rewrite is usually a bad idea that will just introduce new bugs and remove existing functionality.

Refactor vs rewrite is basically the software development equivalent of reform vs revolution in political science and everybody with even a minimal knowledge of history knows that revolutions usually end badly with an even worse regime taking power. Likewise, the failure to accept the need for reform (i.e. refusing to allow refactoring) inevitably leads to revolution.

Re: Things You Should Never Do, Part I (2000)

#27
post #13
post #10

Earlier quoted context omitted.

50-100K LOC are less than the amount of code for the build system in a couple of projects I worked on.

Then you've got bigger problems

You would think that it would have been standardised by 2024, but building stuff is still a surprisingly hard problem.

Re: Things You Should Never Do, Part I (2000)

#28

I think people tend to want to rewrite software for the psychological break from the old, bad and ugly thing they don't want to have anything to do with anymore. It is so easy to think "If only I could start everything from scratch, life will be so beautiful and I will be so successful and everybody will be happy. I will fix all the problems of the current codebase and people will forever sing songs about how amazing…

In my experience, the biggest factors are:

* Many developers prefer working on greenfield code rather than adding to an old codebase

* Working on a rewrite buys you some time in limbo where you can write code while being free from the burdens of production operations. This period is shorter than people dream, but it's often long enough for developers to pitch a rewrite for 6 months, code for 12 months and then skip to the next job with "Spearheaded rewrite of critical infrastructure" on their resume. Time it right and you can get out of there before you have to support the code you wrote.

Re: Things You Should Never Do, Part I (2000)

#29
post #8

I keep hearing this nonsense over and over. I've led two full and very successful software 50-100K LOC rewrites, both with the team and stakeholders who had a lot of experience in the problem space. We replaced unmaintainable systems by a much fresher, MUCH faster codebase. They used largely boring and reliable technology. Rewriting 1%, 10% or even 50% would make no sense and essentially get us little or nothing. Yes…

that's a tiny project. call back when you've got millions of lines

The thing is, there are a lot of small systems maintained by a lot of small teams. Unfortunately, when Joel wrote

“They did it by making the single worst strategic mistake that any software company can make: They decided to rewrite the code from scratch.”

some people took the “any software company” to heart and now apply the same principle even in those smaller contexts when sometimes the code really is that bad and rewriting the whole thing really is by far the best plan. I’ve seen very senior people citing the Netscape case study to support a no-rewrite position while discussing a 10kLOC system that could be rewritten from scratch in a couple of weeks by a single developer.

Re: Things You Should Never Do, Part I (2000)

#30
post #5

I always thought it was easier to read code than to write it.

Other way around in my estimation.

I've read every line of a 300,000 line web application in less than a year working at a company. I doubt I could write that many lines of code in that amount of time.
Post reply on HN