this post was submitted on 07 May 2024
623 points (97.6% liked)

Programmer Humor

19589 readers
516 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 50 comments
sorted by: hot top controversial new old
[–] henfredemars@infosec.pub 123 points 6 months ago (5 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 65 points 6 months ago* (last edited 6 months ago) (3 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.

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

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

[–] geogle@lemmy.world 69 points 6 months ago

72 characters per line/card.

load more comments (2 replies)
[–] mkwt@lemmy.world 21 points 6 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.

load more comments (1 replies)
[–] xmunk@sh.itjust.works 18 points 6 months ago (1 children)

I vomit whenever I have to read one letter alias SQL. And then.... I dealias it.

[–] nogooduser@lemmy.world 8 points 6 months ago (1 children)

I don’t understand why people think that it’s acceptable.

As developers, we’ve had it drummed into us from day one that variable names are important and shouldn’t be one or two letters.

Yet developers deliberately alias an easy to read table name such as “customer” into “c” because that’s the first letter of the table. I’m sure that it’s more work to do that with auto completion meaning that you don’t even need to type out “customer”.

load more comments (1 replies)
load more comments (3 replies)
[–] owenfromcanada@lemmy.world 74 points 6 months ago (2 children)

Nah, I name all my variables after my homies.

int dave = 0;

[–] rufus@discuss.tchncs.de 34 points 6 months ago (2 children)

does dave know he's a zero?

[–] owenfromcanada@lemmy.world 53 points 6 months ago (1 children)

In zero-based indexing, zero is #1.

[–] imPastaSyndrome@lemm.ee 8 points 6 months ago (1 children)
load more comments (1 replies)
[–] codfishjoe@lemmy.world 13 points 6 months ago* (last edited 6 months ago)

His best friends index starts at 0

load more comments (1 replies)
[–] Malix@sopuli.xyz 55 points 6 months ago (1 children)

installing operating system: 15 minutes, give or take.

give a name to the computer: 45 minutes

[–] SturgiesYrFase@lemmy.ml 16 points 6 months ago (1 children)

I've got that shit on lockdown man.
I name all my devices "Fuck0ff" followed by a 3 letter descriptor of what it is. E.g. - my windows install is Fuck0ffDTW for Desktop Windows, my Garuda install is Fuck0ffDTG for Desktop Garuda(it's a flavour of Arch, btw)

[–] OfficerBribe@lemm.ee 8 points 6 months ago* (last edited 6 months ago) (1 children)

What if you would have 2 devices of same type with same OS or just with OS that starts with same letter? Will you use numbers, if yes, how much leading zeroes if any you will use? If you don't use numbers, will you add a room name? But what if there are 2 devices with same OS in the same room?

load more comments (1 replies)
[–] NegativeLookBehind@lemmy.world 51 points 6 months ago (2 children)

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

[–] LostXOR@fedia.io 37 points 6 months ago

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

[–] rufus@discuss.tchncs.de 12 points 6 months ago (4 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 17 points 6 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

load more comments (3 replies)
[–] MentalEdge@sopuli.xyz 41 points 6 months ago* (last edited 6 months ago) (1 children)

FullSentenceExplainingExactlyWhatItDoes(GiveThisVariable, SoItCanWork)

[–] steventhedev@lemmy.world 38 points 6 months ago (1 children)

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".

[–] olutukko@lemmy.world 8 points 6 months ago

I had this problem in my job as a drafter. I was wondering why the hell Tekla would complain about the same object name already being in use despite everything having its own name. took me way too long to realize there wad some stupidly max name length and the program did nothing to alarm the user about trying to put too long name. it just cut the overflow away.

[–] DarkSurferZA@lemmy.world 30 points 6 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 20 points 6 months ago (5 children)

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

load more comments (5 replies)
[–] FrostyCaveman@lemm.ee 27 points 6 months ago (3 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 20 points 6 months ago (3 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.

load more comments (3 replies)
[–] Cethin@lemmy.zip 9 points 6 months ago (4 children)

X, y, and z should only be used when working with things with dimensions larger than 1. Indexing into a 2D array, x and y are great uses. I'm also totally fine with i and j for indexer/iterator when appropriate, but I hate when people try to make short variable names for no good reason. We have auto-complete just about everywhere now. Make the names descriptive. There's literally no reason not to.

load more comments (4 replies)
load more comments (1 replies)
[–] ZILtoid1991@lemmy.world 27 points 6 months ago (3 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 13 points 6 months ago (3 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.

load more comments (3 replies)
load more comments (2 replies)
[–] lars@lemmy.sdf.org 27 points 6 months ago

An important professor constantly and frustratingly said

we can call this variable whatever we want, so we’ll call it Fred

Made me panic and irate and focus on the wrong part of the problem. Every. Single. Time.

[–] aisteru@lemmy.aisteru.ch 23 points 6 months ago (1 children)

There are only two hard things in computer science: cache invalidation and naming things.

[–] gudu@programming.dev 37 points 6 months ago (2 children)
[–] apotheotic@beehaw.org 8 points 6 months ago

Yeah, there are 2 hard things.

0: off by one errors 1: cache invalidation 2: naming things

load more comments (1 replies)
[–] some_guy@lemmy.sdf.org 21 points 6 months ago

Why is no one giving credit to my friend n?!

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

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

load more comments (1 replies)
[–] explodIng_lIme@lemmy.world 17 points 6 months ago (2 children)
load more comments (2 replies)
[–] gandalf_der_12te@discuss.tchncs.de 16 points 6 months ago

How to write spaghetti code:

[–] Strawberry@lemmy.blahaj.zone 15 points 6 months ago (4 children)

mathematician here, where is the joke?

[–] BleatingZombie@lemmy.world 23 points 6 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

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

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

load more comments (1 replies)
load more comments (1 replies)
[–] KillingTimeItself@lemmy.dbzer0.com 8 points 6 months ago (2 children)

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....

load more comments (2 replies)
load more comments (2 replies)
[–] RandomVideos@programming.dev 15 points 6 months ago (1 children)

Since a lot of the english words i know i learned from minecraft, in a farming simulator i named tilled soil"hoed"

I had multiple variables like int isHoed

load more comments (1 replies)
[–] perviouslyiner@lemmy.world 9 points 6 months ago (1 children)

Just be careful naming your function "stdout()" or things could get weird...

[–] mkwt@lemmy.world 12 points 6 months ago

Or Fortran variables that collide with Fortran built-in functions.

Keep in mind that array subscript and function call are both () in Fortran.

[–] Daft_ish@lemmy.world 9 points 6 months ago (1 children)

Now I want to become a programmer so I can give variables people names.

load more comments (1 replies)
[–] MonkderDritte@feddit.de 8 points 6 months ago* (last edited 6 months ago)

No, that's math.

load more comments
view more: next ›