this post was submitted on 13 Nov 2025
1114 points (99.1% liked)

Programmer Humor

27853 readers
530 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
(page 3) 44 comments
sorted by: hot top controversial new old
[–] Kazumara@discuss.tchncs.de 2 points 4 weeks ago

With the short variable you probably also get shadowing. That's super fun in a new code base.

Or another favourite of mine: The first time I had to edit a perl script at work someone had used a scalar and a hash with the same name. Took me a while to realize that scalars, arrays, and hashes have separate namespaces, and the two things with seemingly the same name were unrelated.

[–] OmgItBurns@discuss.online 2 points 3 weeks ago

I once worked with a guy who would actively remove everyone else's comments any time he touched someone else's code. Only comments he made during code reviews? "Does this comment need to be here?". The code was a barren, commentless place.

[–] ozymandias@lemmy.dbzer0.com 1 points 3 weeks ago

more than half of the code is commented out but you’re not allowed to remove it

[–] JasonDJ@lemmy.zip 1 points 1 month ago* (last edited 1 month ago) (2 children)

Fork the repo.

Ask an LLM to rename all the variables and add comments and docstrings. Give it your style guide (assuming you have one).

Ask another LLM to check their work.

Done.

Disclaimer: I'm not a programmer, I'm a network engineer who dabbles in automation and scripting. But it seems to me that grunt work like this is what LLMs are really good for.

Also I only use short variable names inside of loops (for i in iterable...). Is that not how it should be done?

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

i and I are acceptable in small loops. But it depends a lot on the language used. If you're in C or bash maybe it's fine. But if you're in a higher level language like C# you usually have built on functions for iterating over something.

For example you have a list of movies you want to get the rating from, instead of doing

for (i = 0; i < movies.length; i++)
    var movie = movies[i]
    ....

Its often more readable to do

movies.forEach { movie -> 
    var rating = movie.rating
    ....
}

Also if you work with tables it can be very helpful to name your iteration variables as row and column.

It's all about making it readable, understandable, and correct. There's no point having comments if you forget to update them when you change the code. And you better make sure the AI comments on the 2000 lines of three letter variables is correct!

[–] JasonDJ@lemmy.zip 2 points 1 month ago* (last edited 1 month ago)

Yeah I script more than anything...python, bash, powershell, etc.

Only terrible code I inherit is the stuff I wrote >=3 months ago. I'll keep saying that three months from now, too.

[–] Gremour@lemmy.world 1 points 1 month ago* (last edited 1 month ago)

In Go, the recommended convention for variable name length is to be proportional to their scope. It is common to use one or few letters long variables if they are local to a few lines loop or a short function.

load more comments
view more: ‹ prev next ›