this post was submitted on 25 Oct 2026
237 points (94.1% liked)

Programmer Humor

33786 readers
2556 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 3 years ago
MODERATORS
 

Mine is that the useState hook is an actual plague on the entire React ecosystem. Regardless of your opinions of React, if you wanna use something then use it right.

you are viewing a single comment's thread
view the rest of the comments
[–] kionay@lemmy.world 21 points 12 hours ago (3 children)

No single letter variable names. Yes I also mean the i in for loops you see in tutorials. Write out "index" or give it a more descriptive name. Doing the typing isn't the hard part of programming, nor the most time consuming, so making it take a teeny tiny bit longer by having longer variable names is more than worth the value of variables the effortlessly describe themselves.

line length is not that big of a problem anymore, we're not on CRTs, people are regularly developing with 4k monitors, we don't need to limit to 40 character lines but even still if you can't possibly think of a way to break up that long of a line and the only thing you can think of to make it shorter is using over-acronymized variable names then you've already lost the plot somewhere

[–] marcos@lemmy.world 1 points 1 hour ago

I do really disagree here. Name lengths should be proportional to the size of their scope.

If your function has 1 line, your local variables should almost all have 1 letter.

[–] Quetzalcutlass@lemmy.world 34 points 11 hours ago* (last edited 11 hours ago) (1 children)

I disagree when it comes to standardized single-letter variable names. They're invaluable when writing dense code for games or other math-heavy applications and you learn to recognize them very quickly.

So i for index in loops (and j, k for nested loops, but you're almost always doing something wrong if you need them); x, y, z for position and h, w for size; r, g, b, a for color data, etc - you'll immediately know what the variable is for at a glance even though it's a single character.

Another benefit is that having related variables be the same character width keeps code visually aligned, which helps with readability.

[–] kionay@lemmy.world 1 points 2 hours ago

I can concede that in games programming (which I'm not a game dev so I often forget about) x, y, and z coordinates are a valid exception.

I would disagree about w and h for width and height, typing them out feels like i for index

I worry about the phrase, "you'll immediately know what the variable is for at a glance even though it's a single character"

how often have you heard developers say that something is simple and it's just because they wrote it? maybe it is obvious, but if it were more verbose it would be just as obvious but without any possibility of misunderstanding

and even if it's obvious now there's no guarantee a future developer doesn't pull that variable out and mutate it or do something else with it, and maybe they should change it at that point but the effort to have it verbosely named from the start is miniscule

[–] onlinepersona@programming.dev 3 points 11 hours ago

I agree. Short, nonsensical, meaningless, artificial variable names make me think the person writing the code is a dinosaur from when they still had punch cards. Get with the times.