News for hackers. Stuff that matters.
Re:FreeBSD replaces bubblesort with mergesort on SYSINTs, re... by Closi on Monday August 21, 2023 @04:26AM (#37206788)
I think we have different definitions of stupid - the original implementation was perfectly fine for the time and requirements it was written for.
Re:FreeBSD replaces bubblesort with mergesort on SYSINTs, re... by winternewt on Monday August 21, 2023 @04:34AM (#37206823)
But it could have been better for no additional effort. Doing something worse when the better option is just as easy suggests incompetence.
Re:FreeBSD replaces bubblesort with mergesort on SYSINTs, re... by kragen on Monday August 21, 2023 @04:42AM (#37206862)
i wouldn't go so far as to say incompetence

even the best of us do stupid things sometimes

Re:FreeBSD replaces bubblesort with mergesort on SYSINTs, re... by Closi on Monday August 21, 2023 @04:51AM (#37206921)
Yeah, but it was working.

And maybe it wasn't 'no additional effort' because they were more confident with quickly writing a bubble sort.

Re:FreeBSD replaces bubblesort with mergesort on SYSINTs, re... by jazzyjackson on Monday August 21, 2023 @05:18AM (#37207076)
Doing something better when you already have something that works suggests a lack of time management xP
Re:FreeBSD replaces bubblesort with mergesort on SYSINTs, re... by winternewt on Thursday August 24, 2023 @08:30AM (#37248023)
At some point there was no sort, and then somebody implemented the sort. That's the point in time that I'm talking about.
Re:FreeBSD replaces bubblesort with mergesort on SYSINTs, re... by throwawaaarrgh on Monday August 21, 2023 @07:27AM (#37208057)
Never underestimate incompetence. It usually succeeds despite itself.

It also could have been apathy: knowing there was a better solution and just not caring what was implemented. I feel like this is more common than incompetence, especially in larger projects or organizations. Nature tends to take the path of least resistance.

Re:FreeBSD replaces bubblesort with mergesort on SYSINTs, re... by ska on Monday August 21, 2023 @12:59PM (#37212260)
> But it could have been better for no additional effort.

Not if it was already written.

I don't know anything about this particular codebase, but one thing I have learned over the years is that when you are tempted to say "such and such decision was stupid" in a production codebase, you are almost always missing something.

Re:FreeBSD replaces bubblesort with mergesort on SYSINTs, re... by moffkalast on Monday August 21, 2023 @05:39AM (#37207233)
Then the requirements were terrible?
Re:FreeBSD replaces bubblesort with mergesort on SYSINTs, re... by Closi on Monday August 21, 2023 @07:02AM (#37207845)
I don't think the 90's developers could have forseen that 2ms on boot would be huge for cloud serverless compute like lamdba.
Re:FreeBSD replaces bubblesort with mergesort on SYSINTs, re... by oblio on Monday August 21, 2023 @07:41AM (#37208156)
True, but a lesson we frequently have to learn over and over again is that the code is in software in widespread use, the only valid values for collection sizes are 0 and N -> ∞.
Re:FreeBSD replaces bubblesort with mergesort on SYSINTs, re... by Closi on Monday August 21, 2023 @07:47AM (#37208197)
> the only valid values for collection sizes are 0 and N -> ∞.

Of course there are valid values below that...

If they were designing to a collection size of N -> ∞ then they shouldn't have used Insertion Sort either then, because it is O(n²) in the worst case.

Re:FreeBSD replaces bubblesort with mergesort on SYSINTs, re... by oblio on Monday August 21, 2023 @07:50AM (#37208222)
True, but make that valid value at least something like 1 million.

It's trivial to start with something that gets human input and someone, somewhere, decides to plug the thing into something else that generates that input.

And we all know that if computers are good at something, it's doing a lot of small things millions of times.

Re:FreeBSD replaces bubblesort with mergesort on SYSINTs, re... by moffkalast on Monday August 21, 2023 @07:39AM (#37208141)
On an OS whose only gimmick is that it's fast and stable? Idk, maybe they could've.

Besides there's little reason for any codebase of any kind of ever contain bubble sort (except for an academic one, showing it as an example of a bad one). We're talking 20 years ago, not 2000 years ago, the basic sorting algorithms were pretty well researched and established by then.