this post was submitted on 13 Apr 2025
593 points (98.1% liked)

Programmer Humor

22693 readers
999 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
top 30 comments
sorted by: hot top controversial new old
[–] Zeppo@sh.itjust.works 108 points 1 week ago (3 children)

Wow, the pi constant naming inconsistency is terrible.

[–] blindbunny@lemmy.ml 27 points 1 week ago (1 children)

These. These are the kind of people on Lemmy.

[–] leraje@lemmy.blahaj.zone 12 points 1 week ago

But its impossible to not notice! Or find aggravating!

[–] JennyLaFae@lemmy.blahaj.zone 12 points 1 week ago (1 children)

I would have chosen THRPI to make the lines match up :3

[–] Ziglin@lemmy.world 3 points 1 week ago

PI2, PI3 is also good.

[–] wise_pancake@lemmy.ca 6 points 1 week ago (1 children)

halve and double are inverses, right?

[–] palordrolap@fedia.io 2 points 1 week ago

For a certain set of inputs, yes. Good luck guessing what that comprises that set even if 1) there's documentation and 2) you read it.

Worse, for all we know, double actually adds a thing to itself, which might accidentally or deliberately act on strings. Dividing by two has no such magic.

[–] kryptonianCodeMonkey@lemmy.world 34 points 1 week ago* (last edited 1 week ago) (4 children)

Everyone is making this same joke now. "They're going to tariff my imports now!" "My PR got flagged for DEI because they thought '#include dr_libs' was about hiring communist physicians." "If I import pandas do I have to pay 145% more now?" Jeez. Enough already. /s

Why can't anyone tell an original joke anymore?! Like a steak joke. You almost never hear someone tell a good joke about steaks. It really is a rare medium well done.

[–] Evkob@lemmy.ca 8 points 1 week ago

You almost never hear someone tell a good joke about steaks. It really is a rare medium well done.

I knew a fortune teller, she was rather short but she told me a great joke about steak. Unfortunately, she went missing a while ago and no one knows where she is.

She's just a small medium at large now.

[–] pineapplelover@lemm.ee 8 points 1 week ago (1 children)

Because of the absurdity of it all. On a whim, mr orange rapist man will put tariffs on anything if he feels upset enough about it. I honestly wouldn't be surprised if elon or trump mentions something about this.

Imagine seeing another headline that the genius Elon scoured through code and found a bunch of #import libs and got rid of them from the Pentagon servers.

[–] kryptonianCodeMonkey@lemmy.world 2 points 1 week ago* (last edited 1 week ago) (1 children)

So... I was just trying to be funny and sarcastic. I added the "/s" as I realized someone was probably going to take me seriously, but probably after you loaded my comment. My bad.

[–] spacecadet@lemm.ee 6 points 1 week ago

But I want to be angry at you about something that is out of both of our control. Let me have my moment!

[–] cupcakezealot@lemmy.blahaj.zone 3 points 1 week ago (1 children)

'#include cpptrace' gays drawing dick outlines over here.

[–] Danitos@reddthat.com 2 points 1 week ago

I know you mean sarcasm, but I still agree with the point being made.

[–] LostXOR@fedia.io 30 points 1 week ago (1 children)

import { fourier, relativity } from "../utils";

Might want to be careful importing Fourier; he might be classified as an illegal immigrant.

[–] SkaveRat@discuss.tchncs.de 6 points 1 week ago (1 children)

I'm waiting for the new version, fourierst

[–] Kissaki@programming.dev 2 points 1 week ago* (last edited 1 week ago)

Try out the fork furrier

[–] andioop@programming.dev 14 points 1 week ago

Whoever made this graphic, it looks pretty attractive just on sheer visuals, props to you

[–] dohpaz42@lemmy.world 7 points 1 week ago (1 children)

We’re cooked if there’s tariffs on JS imports.

[–] massive_bereavement@fedia.io 4 points 1 week ago

Python sci devs sweating bullets looking at this.

100% tariffs on javascript developers who don't know what graceful degradation is

[–] hperrin@lemmy.ca 5 points 1 week ago

I love importing functions then redeclaring them in useless ways. I also love importing constants that are already part of the language.

[–] Ephera@lemmy.ml 3 points 1 week ago (2 children)

import * as operations from "Math";

Wow, I knew import syntax with a separate from statement could be awkward, but that's a new one for me.

Apparently, the * cannot be used to import all symbols underneath a module (you always have to specify the as moduleName), so I guess, that makes it somewhat less weird for referring to the module itself.

From what I can tell, there's also no obvious other keyword they could've used:

  • package is only a keyword in strict mode.
  • self is not a keyword.
  • this is kind of awkward.
  • Leaving out the keyword is kind of awkward (import as operations from "Math";).
  • Changing up the whole syntax for this one case is awkward, too (import from "Math" as operations;).

So, I guess, I'll allow it, but I'm still not happy about it...

[–] pivot_root@lemmy.world 4 points 1 week ago* (last edited 1 week ago) (1 children)

JavaScript was a mistake, but this is one of the few things they did correctly. Implicitly importing everything from a package into the current scope makes it difficult to follow where variables or functions come from, and it's prone to cause problems when two packages export the same identifier.

If you're an absolute masochist, there's always a workaround. Against all best practices, you can use the deprecated with statement. Or, you can Object.assign() the packages into the global object like a monster. Or if you're using node, you can use the node:vm module to create a new V8 context with its own global object of your choosing.

[–] Ephera@lemmy.ml 2 points 1 week ago

Oh yeah, I was merely complaining about the syntax. Coming from other languages, I interpreted that import statement to mean essentially this:

import { double, exponent /*...*/ } as operations from "Math";

...and as such, it took me a few seconds to understand what's being aliased by as operations.

As for importing all symbols of a module, I do think it's more harm than good in non-compiled languages. But when it comes to compiled languages, I'd say it depends on the language.

In Rust, for example, I can easily throw down an inline module with one-way isolation, so that it can transparently access everything in its parent module via use super::*;, while the parent module can't access what's in the module (unless it's been marked pub). That can reduce mental complexity of the code (and is actually used a lot, because unit tests are typically put into such an inline module).
It's also useful in Rust, because you can re-export symbols in different modules, so you can break up a file without breaking the imports by throwing a pub use my_sub_module::*; into the original module.

But yeah, on the flipside, I really wouldn't miss it, if it didn't exist in Java. It was rather even annoying, because the popular IDEs have a rule to replace explicit imports with an asterisk as soon as it reached 5 symbols imported from the same module.
It's not as bad as one might think, because you can't declare top-level functions or variables in Java (everything has to be in a class), but it still sometimes led to those asterisk imports bringing in the wrong class names, so I'd have to manually add the import I wanted underneath them...

[–] AnUnusualRelic@lemmy.world 3 points 1 week ago (1 children)

You mean I can't just

import * from * 

And be done with it? How inefficient!

[–] demunted@lemmy.ml 1 points 1 week ago

Calm down Thanos

[–] fubarx@lemmy.world 2 points 1 week ago* (last edited 1 week ago)
[–] ArchmageAzor@lemmy.world 1 points 1 week ago

You know, I actually think Trump would try if he knew about Javascript.