News for hackers. Stuff that matters.
Re:Why do we fall into the rewrite trap? by btilly on Tuesday January 21, 2020 @04:12PM (#22111622)
There is still more to the story though. When Netscape went under and open sourced their code, they had to rip out all of the proprietary bits. The result? What they had didn't actually run!

It wasn't a question of rewriting working code. It was a question about whether the better path forward was to try to fix what they had and didn't understand, or whether to rewrite into something that they understood.

In other words, Joel set up a straw man argument.

Re:Why do we fall into the rewrite trap? by goto11 on Tuesday January 21, 2020 @04:57PM (#22112104)
They could just rewrite the components which they didn't own, then. They would have to do that anyway.

I'm not sure what you mean with "didn't understand". It was their own code. They could just read it.

Re:Why do we fall into the rewrite trap? by oldandtired on Tuesday January 21, 2020 @05:28PM (#22112373)
To write "It was their own code. They could just read it." misses a great deal about code bases. The first and foremost is that the vast majority of working code bases do NOT have sufficient internal documentation to actually understand whys and wherefores of that code base.

The specific reasoning for doing something or using a specific technique or why the magic numbers, etc., are often not put into any form of accessible documentation. This is just a fact of life. Documenting such things can be very tedious and often thought of as not being needed because the code is "obvious". Yet to someone coming in to do work on it in six months let alone six years, it is vital missing information.

{Edits spelling mistakes - should have checked before submitting}

Re:Why do we fall into the rewrite trap? by goto11 on Wednesday January 22, 2020 @02:29AM (#22115397)
Code often sucks, but a rewrite from scratch doesn't change anything. The rewritten code will suck just as much, but now you just lost a lot of time and have new bugs.
Re:Why do we fall into the rewrite trap? by btilly on Tuesday January 21, 2020 @05:50PM (#22112608)
I'm not sure what you mean with "didn't understand". It was their own code. They could just read it.

I meant exactly what I said.

The missing proprietary bits were not their own code. There was nothing to read and no documentation. They could see the call, and that something important happened, but what it did and how it should work was guesswork.

Furthermore key people were gone. How the code that they had was supposed to work is harder to dig out than you might think. Read http://pages.cs.wisc.edu/~remzi/Naur.pdf for an explanation of why.

Just to add to the fun, just getting the browser running wasn't enough. Netscape and IE were incompatible all over the place, on everything from how styling worked to what order event handlers ran. (In IE, the thing you clicked on gets the event first. In Netscape, the window did. That's a pretty fundamental difference!) They needed to not just have a running browser, but have a browser with enough IE compatibility that it could be usable on webpages designed for IE. It is easier to design something to be compatible from scratch than to find out what deep assumptions need to be changed in existing code to fix incompatibilities.

As fun as it was for Joel to beat up on them for their choice, their choice was arguably the best way forward given the actual situation.

Re:Why do we fall into the rewrite trap? by jasode on Tuesday January 21, 2020 @06:28PM (#22112911)
>The missing proprietary bits were not their own code. There was nothing to read and no documentation. They could see the call, and that something important happened, but what it did and how it should work was guesswork.

To your point, the following link is another famous example of smart programmers not being able to easily understand someone else's source code. Raymond Chen at Microsoft couldn't easily figure out why Pinball didn't work in 64bit Windows and gave up:

https://devblogs.microsoft.com/oldnewthing/20121218-00/?p=58...

Re:Why do we fall into the rewrite trap? by goto11 on Wednesday January 22, 2020 @02:20AM (#22115360)
I'm sure they could have figured it out if it was important enough. They just decided it was not worth it and scrapped the product instead.

"we couldn’t afford to spend days studying the code trying..."

So the estimated time to fix the bug was on the scale of days. It would certainly have taken longer to rewrite the game from scratch if that was the alternative.

Re:Why do we fall into the rewrite trap? by wildmusings on Wednesday January 22, 2020 @03:54AM (#22115814)
I’ve never understood why they had to port it at all. The 32-bit version of Pinball would have kept working just fine. And apparently, the binary from Windows XP still runs on Windows 10.
Re:Why do we fall into the rewrite trap? by goto11 on Tuesday January 21, 2020 @06:19PM (#22112845)
What kind of stuff was these third-party bits then? I would have thought it was stuff like say a jpeg decoder library.
Re:Why do we fall into the rewrite trap? by btilly on Tuesday January 21, 2020 @07:05PM (#22113181)
I only know about this second hand..

Back when Joel's article was written there was also a response to it written by someone who was part of the decision. And that was one of the big points that stuck with me.

There were dozens of proprietary components that had to be removed. Java being the biggest (because it had been integrated into every part of the browser). They succeeded in removing them, but after 2 years of trying to fix the result, everything from print preview to text selection was broken. That was when they decided to scrap and rewrite.

Now consider. You've had 100 engineers working for 2 years and you don't have a functioning product or a realistic timeline for getting one. How many more years are you planning to throw into it before deciding that you're going down a dead end?

Now let's throw a monkey wrench into this. The main reason that the product is being funded was as a bargaining chip. Specifically, AOL had a deal with Microsoft to bundle a specially branded version of IE. And had every reason to believe that when the contract expired, Microsoft was not going to renew. AOL didn't care about browser market share, they wanted to have a viable alternative if Microsoft refused to negotiation. (As it turns out, Microsoft renewed the deal but part of the price was that AOL had to stop supporting Mozilla...)

Re:Why do we fall into the rewrite trap? by goto11 on Wednesday January 22, 2020 @02:09AM (#22115305)
So they had to change the Java integration to some kind of plug-in interface. Perhaps not trivial, but it would not require you to rewrite everything from the ground up. And it was well-understood what Java does. If it wasn't you still would have to figure it out in order to do the rewrite.

> Now consider. You've had 100 engineers working for 2 years and you don't have a functioning product or a realistic timeline for getting one.

You are definitely in serious trouble when it get to that point. But if you can't make a realistic estimate for fixing text selection, how can you make a realistic estimate for the much larger and more complex task of rewriting everything from scratch? What if they rewrite everything, but then after four years of work still can't get text selection to work?

Re:Why do we fall into the rewrite trap? by AstralStorm on Wednesday January 22, 2020 @04:24AM (#22115943)
What if the development team is not by a bus? What if they're suddenly replaced with chimpanzees?

Literally collecting all the problems with the current code base and designing around them is the only thing anyone can reasonably do.

If you have a poor development team, you're just screwed - hire a better one. The problem there is figuring whom you can keep and in which position. Since nobody knows how to grade programmers (and stupid algorithmic tests do not work for design and engineering which is critical) you get to try until you run out of money and perhaps rely on peer or expert opinion.

As a point of reference, rewriting a GUI with a layout engine (not a web browser but a music editor, shares a lot of design) took a small team half a year and solved all of the problems reported and a bunch of others. Including performance. At 4 months we had an almost matching result with exclusion of single issues that took additional redesign. (Asked client if they already want to keep it, they said to finish it.) And the testing was limited to manual checklists. A web browser is bigger and testing somewhat easier to automate.

The true important thing we did is dig into requirements including fuzzy ones and designed using good practices making change easy. (Including a few times when the client just changed the requirements.)

Re:Why do we fall into the rewrite trap? by btilly on Wednesday January 22, 2020 @01:43PM (#22120582)
So they had to change the Java integration to some kind of plug-in interface.

No. They had to remove it entirely because back in 1998 there was no open sourced version of Java that was compatible with their license.

And it wasn't just that they had to rip out Java. The browser had been partly written in Java, and THAT was ripped out as well. And the parts that had been in Java needed to be rewritten.

But if you can't make a realistic estimate for fixing text selection, how can you make a realistic estimate for the much larger and more complex task of rewriting everything from scratch?

Because the second task is inherently easier to estimate.

Fixing a broken large code base involves a lot of chasing down rabbit holes to figure out what isn't working, what depends on what, etc. When you start down a rabbit hole you have no idea how deep it goes, or what else you are impacting. This is why maintenance is harder than writing fresh code. Furthermore entropy says that code will not improve through this process. Costs only go up.

Estimating a rewrite is a question of coming up with a clean design for the rewrite, and then estimating how long that design will take. This is still a notoriously hard problem to solve. But it is much easier in principle than estimating the depth of rabbit holes. And if your design is clean, there is little chance of not being able to get a feature like text selection to work.

Re:Why do we fall into the rewrite trap? by goto11 on Wednesday January 22, 2020 @05:54PM (#22122961)
But you are assuming the result of the rewrite will be cleaner and have less rabbit holes. There is no reason to think that. If it is developed by the same organization it will probably end up with the same level of quality. Perhaps worse since it will suffer from second-system effect.

Indeed Netscape 6 was more buggy than any of the previous versions.

Re:Why do we fall into the rewrite trap? by btilly on Thursday January 23, 2020 @04:58PM (#22132660)
Doing emergency surgery on a code base and not knowing how many holes are left is likely to leave more rabbit holes than a rewrite.

Otherwise I agree with you. Rewrites are tricky. And the second system is particularly dangerous. But then it gets better - the third system tends to be a lot better than either of the first two.