this post was submitted on 14 Feb 2026
454 points (99.8% liked)

Programmer Humor

30700 readers
2501 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] bleistift2@sopuli.xyz 148 points 1 month ago (2 children)

One way in which this could have come about is that Math.random wasn’t supported in all relevant browsers when the library author wrote the library. So they had to roll their own randomness with blackjack and hookers. Later the web standards evolved and the author was able to remove the custom code, but now had people relying on his library’s exposing a getRandom function.

[–] Billygoat@piefed.social 49 points 1 month ago (1 children)

You see this kind of stuff in C all the time when a code base supports multiple OSs by using macros.

[–] chonglibloodsport@lemmy.world 30 points 1 month ago

Yes, though at least with C you have the compiler to optimize the cruft out of your binary and end up with a nice, clean program.

With JavaScript this is going to incur some runtime cost everywhere this library is used, even if it only happens once when getting optimized out by the JIT compiler.

[–] TrickDacy@lemmy.world 10 points 1 month ago* (last edited 1 month ago) (2 children)

Pretty sure that math.random is decades old.

[–] bleistift2@sopuli.xyz 34 points 1 month ago (1 children)

Pretty sure OP’s image is hyperbole.

[–] TrickDacy@lemmy.world 6 points 1 month ago

Right. I'd agree this is a thing that happens, I just thought you were addressing this one in particular

[–] meekah@discuss.tchncs.de 6 points 1 month ago (3 children)

Pretty sure many codebases running today (even JS ones) are older

[–] Sv443@sh.itjust.works 10 points 1 month ago (2 children)
[–] sparky@lemmy.federate.cc 2 points 1 month ago

Remember IE? Yeah. Probably responsible for a lot of now-superfluous things like this theory suggests.

[–] meekah@discuss.tchncs.de 1 points 1 month ago

Gotta admit, didn't think it was that old

[–] Ajen@sh.itjust.works 5 points 1 month ago

How many JS codebases are over 30 years old? Can you name even one?

[–] TrickDacy@lemmy.world 2 points 1 month ago

And? I don't know how to check but I'd guess math.random was included from the beginning.