this post was submitted on 07 May 2024
3 points (100.0% liked)

Programmer Humor

18971 readers
744 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 1 year ago
MODERATORS
top 44 comments
sorted by: hot top controversial new old
[–] MentalEdge@sopuli.xyz 1 points 3 months ago* (last edited 3 months ago) (1 children)

FullSentenceExplainingExactlyWhatItDoes(GiveThisVariable, SoItCanWork)

[–] steventhedev@lemmy.world 1 points 3 months ago

Older C compilers would truncate a variable name if it was too long, so VeryLongGlobalConstantInsideALibraryInSeconds might accidentally collide with VeryLongGlobalConstantInsideALibraryInMinutes.

Legend says that they used to do it after a single letter with Dennis declaring "26 variables ought to be enough for anyone".

[–] ZILtoid1991@lemmy.world 1 points 3 months ago (1 children)

Then you realize your code is undebuggable because half the functions and variables have single-letter names or called foo, bar, baz, etc.

[–] ObsidianNebula@sh.itjust.works 0 points 3 months ago (1 children)

I have a somewhat related real world story. I had a client that was convinced that tons of people were going to decompile their application and sell their own version of the program, so they insisted that they needed their code obfuscated to protect company secrets and make it harder to reverse engineer. I tried explaining to them that obfuscation wasn't that big of a deterrent to someone attempting to steal code through reverse engineering and that it would likely cause some issues with debugging, but they were certain they needed it. Sure enough, they then had a real user run into an issue and were surprised to find that their custom logging system was close to useless because the application was outputting random obfuscated letters instead of function and variable names. We did have mapping files, but it took a lot of time to map each log message to make it readable enough to try to understand the user's issue.

[–] Johanno@feddit.de 0 points 3 months ago (1 children)

This is why you obfuscate after you code. Just obfuscate the release build. And logging may at that point be thrown out of the window anyway

[–] ObsidianNebula@sh.itjust.works 0 points 3 months ago* (last edited 3 months ago) (1 children)

It was obfuscated only in the release build. The issue is that they have a system to send certain logs to an API so they can refer to them if a user has an issue that needs further investigation. Unfortunately, their target audience is not very tech literate and have a hard time explaining how they got into a situation where they experienced a bug, so the remote logging was a way to allow us to try to retrace the user's steps. Some of the logs that get sent to the API have JSON values converted from class data, will refer directly to class names, etc, and those logs had the obfuscated names.

[–] Johanno@feddit.de 0 points 3 months ago

Well then you are fucked.

The question is if nobody else has access to the logs, then obfuscation is stupid

[–] NegativeLookBehind@lemmy.world 1 points 3 months ago (2 children)

You should really be naming all your variables by generating 64 character (minimum) random strings.

[–] rufus@discuss.tchncs.de 1 points 3 months ago (1 children)

Make it 63 (31?) to align with what C99 can distinguish.

Also: I really like unicode in identifiers. So if at all possible don't just have a random string of letters and numbers, make sure to include greek letters and all the funny emojis. (I just forgot which languages and compilers etc allow that.)

[–] BodilessGaze@sh.itjust.works 1 points 3 months ago

For extra fun, you can name your variables using solely Unicode invisible characters (e.g. non-breaking space) so they're impossible to visually distinguish

[–] LostXOR@fedia.io 1 points 3 months ago

Who needs private variables when you can generate cryptographically secure variable names? Much better security.

[–] FrostyCaveman@lemm.ee 1 points 3 months ago (1 children)

Single character variable names are my pet peeve. I even name iterator variables a real word instead of “i” now.. (although writing the OG low level for loops is kinda rare for me now)

Naming things “x”.. shudder. Well, the entire world is getting to see how that idea transpires hahah

[–] Mikelius@lemmy.ml 0 points 3 months ago (1 children)

I hate short variable names in general too, but am okay with them for iterators where i and j represent only indices, and when x/y/z represent coordinates (like a for loop going over x coordinates). In most cases I actually prefer this since it keeps me from having to think about whether I'm looking at an integer iterator or object/dictionary iterator loop, as long as the loop remains short. When it gets to be ridiculous in size, even i and j are annoying. Any other short names are a no go for me though. And my god, the abbreviations... Those are the worst.

[–] FrostyCaveman@lemm.ee 0 points 3 months ago (1 children)

That’s very reasonable, I can get behind that. (my stance is a partly irrational overreaction and I’m totally aware of it lol)

Abbreviations are definitely annoying. My least favourite thing to do with them is “Hungarian notation”. It’s like.. in a statically typed context it’s useless, and in a dynamically typed context it’s like.. kind of a sign you need to refactor

[–] Cethin@lemmy.zip 1 points 3 months ago

Hungarian notation makes sense in a dynamically typed usage (which I despise, but this essentially makes them notationally typed at least) or where you're editor/IDE is so simple it can't give you more information, which I can't see ever being the case in the modern day.

[–] Strawberry@lemmy.blahaj.zone 1 points 3 months ago (3 children)

mathematician here, where is the joke?

[–] humbletightband@lemmy.dbzer0.com 1 points 3 months ago (1 children)

This joke is funny only if placed in Arnold-Atyah manifold if Kolmogorov-Ramachandran-Yu metric is defined

[–] CanadaPlus@lemmy.sdf.org 1 points 3 months ago* (last edited 3 months ago)

So don't use it in non-KRY-definite AA situations, or you could get erroneous results. QQX is fine though, as long as you have non-vanishing ABCD. /s

I wonder if Lean proofs become the new peer review like I've heard suggested, if mathematics might break from this, and look more compsci-ish in the future. That way non-specialists could get up to speed quickly.

in the linux community it's really common to have applications like MPD, music player daemon, or MPC, music player client, and ncmpc, ncurses music player client, and ncmpcpp the aforementioned one with ++ tacked onto the end.

Cmus, which from what i can recall is literally "c music player"

etc....

[–] BleatingZombie@lemmy.world 0 points 3 months ago (2 children)

Variable names should be "self defining" meaning you should be able to understand what its doing from the name. The name also shouldn't be too long. Combining those together makes it difficult to come up with an "elegant" name

[–] menas@lemmy.wtf 1 points 3 months ago

tmp3 = tmp1 + tmp2 ; T.T

[–] PotatoesFall@discuss.tchncs.de 1 points 3 months ago (1 children)

I think they got the joke, they were just joking about how this is common in math :P

[–] Strawberry@lemmy.blahaj.zone 0 points 3 months ago

The most atrocious variable names I ever encountered in code were as a research assistant for a math professor doing game theory simulations. Literally unreadable unless you had a copy of his paper on the subject to refer to

[–] JATtho@sopuli.xyz 1 points 3 months ago (1 children)

name your function as malloc() and see to world burn and generate bugs at factorial rate.

[–] trolololol@lemmy.world 1 points 3 months ago

If you name it malloc it will be easy to notice. On the other hand if you call it free....

[–] henfredemars@infosec.pub 1 points 3 months ago (1 children)

I worked with a developer who insisted on using the shortest names possible. God I hated debugging his code.

I’m talking variable names like AAxynj. Everything looking like matrix math.

[–] redcalcium@lemmy.institute 1 points 3 months ago* (last edited 3 months ago) (2 children)

Ah, must've been a fortran developer. I swear they have this ability to make the shortest yet the least memorable variable names. E.g. was the variable called APFLWS or APFLWD? Impossible to remember without going back and forth to recheck the definition. Autocomplete won't help you because both variables exist.

[–] mkwt@lemmy.world 1 points 3 months ago

And you can write more than six characters, but only the first six are recognized. So APFLWSAC and APFLWSAF are really the same variable.

And without namespaces, company policy reserves the first two characters for module prefix and Hungarian notation.

[–] henfredemars@infosec.pub 0 points 3 months ago (1 children)

He did write some Fortran in his past! What made you think it was Fortran influence?

[–] geogle@lemmy.world 1 points 3 months ago

72 characters per line/card.

[–] Kolanaki@yiffit.net 0 points 3 months ago (1 children)

Was just talking about gaming genre names being kinda lame (roguelike? Souls-like? Where's the originality?!) and this just furthers my point as programming and video games are intrinsically linked.

[–] outer_spec@lemmy.blahaj.zone 1 points 3 months ago

floats, doubles, etc are decimallikes. object-oriented programming languages are c++likes. a string that is just the word “false” is a boollike. any language easier to learn than c++ is a pythonlike. any language harder to learn than c++ is a asmlike. don’t like it? then you’re a naglike. you don’t want to be known as a naglike, do you?

[–] explodIng_lIme@lemmy.world 0 points 3 months ago (1 children)
[–] Buddahriffic@lemmy.world 1 points 3 months ago

for myList in myElement:

[–] DarkSurferZA@lemmy.world 0 points 3 months ago (1 children)

Gotten even easier after X became a registered trademark. Now the only choice we have left is i. Or ii if you need more variables

[–] Cethin@lemmy.zip 0 points 3 months ago (1 children)

"j" is what you're supposed to use if you need another index variable after using "i".

[–] Bougie_Birdie@lemmy.blahaj.zone 0 points 3 months ago (1 children)

Okay, say you've got four inner loops (a crime on its own, I know), do you use i, j, k, l or i, j, k, ii?

[–] cbazero@programming.dev 1 points 3 months ago

lIIl, IIIl, lIlI and IllI

[–] owenfromcanada@lemmy.world 0 points 3 months ago (1 children)

Nah, I name all my variables after my homies.

int dave = 0;

[–] rufus@discuss.tchncs.de 1 points 3 months ago

does dave know he's a zero?

[–] kromem@lemmy.world 0 points 3 months ago (1 children)

Ok, but what variable is 🐈?

[–] driving_crooner@lemmy.eco.br 1 points 3 months ago

Is the function to con🐈eate and print.

[–] MonkderDritte@feddit.de 0 points 3 months ago* (last edited 3 months ago)

No, that's math.