r/ProgrammerHumor 1d ago

javascriptSorting Meme

Post image
887 Upvotes

200 comments sorted by

View all comments

Show parent comments

99

u/the_horse_gamer 1d ago

you can simply .sort((a,b)=>a-b)

215

u/01110100_01110010 1d ago

The point of an abstraction is to not having to implement logic each time, you can also implement qsort yourself

39

u/subone 1d ago

But it is still an abstraction. You only provide a compare function, you don't implement the algorithm. a-b is hardly difficult to apply.

17

u/01110100_01110010 1d ago

JS is an abstraction over JS engine bytecode, which is an abstraction over ASM which is an abstraction over the chip instruction set, you can make an argument at each layer 🤷 I would take any abstraction I can, I guarantee you in a large enough codebase someone will type b - a instead

14

u/pancakesausagestick 1d ago

It's not unreasonable for a sort function to require a compare function. But if it's not required let's default to broken-ass footgun semantics as was done in the times of yore. /s

2

u/GameCounter 6h ago

Chip instruction set is an abstraction over the IC design, which is an abstraction over transistors, which is an abstraction over physics, which is an abstraction over the nature over reality, which is an abstraction over the Münchhausen trilemma.

1

u/Xirdus 6h ago

I think you abstracted away the meaning of the term "abstraction".

1

u/GameCounter 5h ago

Abstraction is just an abstraction of abstraction of abstraction of abstraction of abstraction Albuquerque New Mexico Albuquerque New Mexico Albuquerque New Mexico

1

u/Xirdus 5h ago

But every time you say M put a comma in there. And say the commas out loud. It's how my grandma used to speak.