this post was submitted on 18 Dec 2025
966 points (98.5% liked)

Programmer Humor

28036 readers
499 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 50 comments
sorted by: hot top controversial new old
[–] ttyybb@lemmy.world 124 points 1 week ago (3 children)

A skilled programmer can make self documenting code, so I always document mine.

[–] SeductiveTortoise@piefed.social 29 points 1 week ago

I inherited a code base probably written by a squirrel, and the first thing I did was to write documentation on infrastructure, business logic, architecture, deployment and whatever. I had to read everything anyways, because the guy handing it over had no idea what it did and left the company shortly after. It's fine now, but that path was horrible.

[–] MotoAsh@piefed.social 21 points 1 week ago* (last edited 1 week ago) (1 children)

Nah. No code actually documents itself. Ever. Anyone who says they can is an idiot that doesn't understand the purpose of comments and docs.

Code can never describe intent, context, or consequences unless you read every line of code in every library and framework used, and every external call. Especially if they aren't doing "fail fast" correctly.

[–] defaultusername@lemmy.dbzer0.com 18 points 1 week ago (1 children)
// Prints "Hello World!" to the screen
printf("Hello World!");
[–] MotoAsh@piefed.social 16 points 1 week ago* (last edited 1 week ago) (1 children)

I did not say comments should directly explain what the code is obviously attempting to do.

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

My favorite thing about the "all comments are bad" crowd is that their first example is almost always something like this:

// Add 1 to x
x = x + 1

Like, nobody that thinks comments are good and important would ever add a useless comment like that. The point of commenting is to add documentation (usually the only form of documentation that a future developer is ever going to read) only to code that would otherwise be inscrutable.

[–] Hudell@lemmy.dbzer0.com 6 points 1 week ago* (last edited 1 week ago) (1 children)

You'd think that, and yet I've once worked in a project in a fortune 500 company that basically wouldn't even compile if we didn't add comments like that. No kidding the compiler enforced specific comment patterns so if you had a line do x = x + 1, it would not compile if it was not preceded by a comment that started with "Add" and included "1" and "to x". Even in dev mode if you wanted to just try something you had to comment everything.

The original dev was super proud of this tools that generated HTML documentation about everything based on those comments. And the whole documentation was stuff like:

*price*: The price
[–] MotoAsh@piefed.social 8 points 1 week ago

Every good idea can be taken to a ridiculous extreme.

and that... is ridiculous.

load more comments (1 replies)
[–] Klear@quokk.au 115 points 1 week ago (4 children)
[–] ttyybb@lemmy.world 54 points 1 week ago (2 children)

What idiot wrote this? It's complete nonsense... Oh right.

[–] Klear@quokk.au 53 points 1 week ago (1 children)

Why the fuck would I do this? This is nonsense. This way is way better.

*half an hour later, when I run into a major, strangely familiar bug*

Ooooohhhh!

[–] Clent@lemmy.dbzer0.com 19 points 1 week ago

That's when a "here be dragons" comment needs to be added.

[–] bitjunkie@lemmy.world 6 points 1 week ago (1 children)

I forget which extension it is but the thing that shows a faint git blame at the end of the line under cursor in VS Code has been… humbling.

load more comments (1 replies)
load more comments (3 replies)
[–] jubilationtcornpone@sh.itjust.works 68 points 1 week ago (3 children)
/*
By all accounts, the logic in this method shouldn't work. And yet it does. We do not know why. It makes no sense whatsoever. It took three weeks and numerous offerings to the programming gods, including using one of the junior devs as a human sacrifice, to unlock this knowledge. DO NOT LET HIS VIOLENT AND UNTIMELY DEATH BE IN VAIN! Touch this at your own peril.
--jubilationtcornpone 12/17/25
*/
public async Task<IResult> CalculateResultAsync()
{
     // Some ass backwards yet miraculously functional logic.
}
[–] ChickenLadyLovesLife@lemmy.world 12 points 1 week ago (1 children)

That long-ass horizontal scroll bar reminds me of how I used to put unfindable easter eggs into my Visual Basic apps. I would have amusing little messages pop up from time to time in message boxes. To prevent anyone from just searching for the exact text in the message box, I would reduce it to a series of concatenated Chr() statements and then I would put like 200 characters of whitespace in front of the message box call. The only way anybody would spot it would be if they noticed the horizontal scroll bar this produced and nobody ever did.

At least that's my theory. It's also possible that nobody ever used the software that I produced.

[–] Hudell@lemmy.dbzer0.com 5 points 1 week ago

A friend of mine used to teach coding decades ago and one story I'll never forget is about the student who had an assignment that asked for a "for" loop to be used, but they didn't quite know how to use it so they just wrote a broken loop there and then hid a "while" loop at the far end of the line.

Code compiled, had a "for" loop and had the right output.

load more comments (2 replies)
[–] RedFrank24@piefed.social 59 points 1 week ago (6 children)

The only times I've seen devs do inline comments in their code is when it's been done by AI, and I can tell it's AI because the comments are all useless and describing what's happening, not why.

[–] Eiri@lemmy.ca 58 points 1 week ago (7 children)
// Format user object
function formatUserObject(user) {

I've seen lots of such crap written by humans. I guess AI had to learn it from somewhere.

[–] Thorry@feddit.org 20 points 1 week ago

AI mostly learned it from programming tutorials and things like documentation and Q&A forums like StackOverflow. People often add comments in those cases to explain to somebody not familiar with code what is happening so they can learn from it.

In actual code written by people who write code for a living I'd hope the comments are much more useful and usually not as prevalent.

load more comments (6 replies)
[–] konalt@lemmy.world 30 points 1 week ago* (last edited 6 days ago) (2 children)
// 🚨 Log error to console
console.error(error);
[–] Thorry@feddit.org 25 points 1 week ago* (last edited 1 week ago)

// 🤦 You are totally right! Simply logging the 🚨 error to the console isn't proper error handling. 🫣 We now throw an exception instead. throw new ApplicationException(error);

[–] tauonite@lemmy.world 5 points 1 week ago* (last edited 1 week ago) (3 children)

I once tried vibe coding a web app using GitHub Copilot. That motherfucker wrapped every single endpoint with

try:
    ...
except Exception:
    return "An error occurred"

What the fuck is wrong with you Copilot? This piece of shit trying to hide all the errors. If I don't know there are errors then there aren't errors. Apparently

load more comments (3 replies)
[–] nogooduser@lemmy.world 15 points 1 week ago (1 children)

I sometimes suspect that I am actually an AI. I’ve always struggled with captchas and I comment my code exactly as you’ve just described.

[–] vrek@programming.dev 7 points 1 week ago (1 children)

Proper comments describe why... For example say you are using an api which requires guids and your application doesn't care are collisions as much so just use int id's.

You could add in a comment like

// creating a guid to interface with special api.

But just saying

// generate guid

Means nothing, your method should be generate_guid() or GenerateGuid(). Your comment is repeating.

Or this is probably going to hit my last company at some point, there was a system to read a serial number. They also wanted a "status" on the screen to verify the system was connected and running properly but both these values came over same signal wire. Depending on your exact ms timing sometimes you would read the status as the serial number. Another programmer wrote a check to verify the serial number did not start with OK. The comment added was

// add on 11/15/23 by Initials

With no other details. The serial numbers were 8 numeric digits. Someone won't know the history and delete this seemingly useless check and cause a 10s of 1000s of dollars in loss

[–] anomnom@sh.itjust.works 6 points 1 week ago* (last edited 1 week ago) (1 children)

I used to write it all the steps I thought I’d need as these types of comments, then go back and write the real methods. But I usually replaced the comments with more detailed jsdocs style comments with as much detail about the parameters as returnvalues as possible.

Then I quit web dev and moved to the woods.

[–] vrek@programming.dev 4 points 1 week ago

Yeah effectively using comments as psuedocode

load more comments (3 replies)
[–] HairyHarry@lemmy.world 40 points 1 week ago (1 children)

Decoding hieroglyphs with an English dictionary should do the work.

[–] bonenode@piefed.social 11 points 1 week ago* (last edited 1 week ago) (1 children)

Especially helpful that it is written right to left. Maybe the Manga version of the English dictionary.

load more comments (1 replies)
[–] umbrella@lemmy.ml 39 points 1 week ago (1 children)

who the fuck wrote this garbage

me. its just me every time.

load more comments (1 replies)
[–] theneverfox@pawb.social 31 points 1 week ago (1 children)

I get regularly complimented on my code for how understandable it is radiates smugness

[–] RonSijm@programming.dev 8 points 1 week ago (1 children)

It's ChatGPT that's commenting this, isn't it?

[–] theneverfox@pawb.social 9 points 1 week ago (1 children)

Nope, sorry. I just break my code into neatly grouped chunks, and I'm very consistent

I regularly go "I need something to do X", and when I go to write it it's already there. It does exactly what I need it to do, otherwise why would I name it X and not X_for_situation_y? I would never

My utility functions are reusable, my classes handle their own logic internally, and so my business logic is clean and readable. My code flows straight and clear, along a single path whenever possible

So yeah... When I start working with people, there's the initial confusion then this moment where they go "Oh! That's really easy to understand"

[–] lime_red@lemmy.world 4 points 1 week ago (2 children)

Can we please download your brain?

[–] theneverfox@pawb.social 4 points 1 week ago

Yes, but only ship of thesius style

I've seen how people code, I'm writing my own stack on the way up

load more comments (1 replies)
[–] Bronzebeard@lemmy.zip 29 points 1 week ago

Who wrote this shit?!

Oh, it was me. Last month.

[–] dejected_warp_core@lemmy.world 28 points 1 week ago (3 children)
[–] hakunawazo@lemmy.world 30 points 1 week ago (1 children)
[–] dejected_warp_core@lemmy.world 5 points 1 week ago (1 children)
[–] harmbugler@piefed.social 4 points 1 week ago* (last edited 1 week ago)

The main reason I put effort into comments

load more comments (2 replies)
[–] spirinolas@lemmy.world 20 points 1 week ago

The moment when you realize you wrote it.

[–] Someonelol@lemmy.dbzer0.com 18 points 1 week ago

I'm living this right now. The lead programmers are long gone for a setup that uses Python, C++, and Linux. The only other guy who knows it is pulled to three other projects and I only have a C++ class taken over 15 years ago under my belt. I'm somehow expected to decipher this shit and explain the function of a few dozen variables and it's going as well as one might expect.

Wait until you write code that is self-hosting!

[–] xxce2AAb@feddit.dk 13 points 1 week ago

"According to all available documentation, your code is utter shit."

[–] leo85811nardo@lemmy.world 11 points 1 week ago (1 children)

Looks like me vs my code after the winter holiday break

I started writing a giant note. On the last day in the morning I start it and add anything that I need to do after the break to it. These are very highly detailed including line numbers ro point me at the exact spot I need, names of bookmarks for reference, page number on documentation, anything that is going to unfuck the morning of the first day I come back.

[–] Sharlot@lemmy.world 11 points 1 week ago

Ah yes, readable code… if you’re fluent in Ancient Developer.

[–] Hupf@feddit.org 10 points 1 week ago
[–] AntiBullyRanger@ani.social 9 points 1 week ago* (last edited 1 week ago)

𓎼𓏏 𓎼𓂧
spoiler gitgud
getgoodreach better[ment]

load more comments
view more: next ›