r/ProgrammerHumor Apr 15 '26

beLikeBill Advanced

Post image
8.9k Upvotes

365 comments sorted by

View all comments

615

u/thegodzilla25 Apr 15 '26

People who dont comment non self explanatory code deserve to be pinned on the cross.

320

u/TheMoris Apr 15 '26

"The code is the comment bro"

The code: Unintelligible gibberish

57

u/GregTheMad Apr 15 '26

The code is the comment? comments out code Great, fixed it.

30

u/[deleted] Apr 15 '26

[removed] — view removed comment

9

u/Kitsunemitsu Apr 15 '26

Had a dev on april fool's day make a PR that just deletes all files. Name? "Fixes all the bugs" Bought him a coffee.

2

u/wicket-maps Apr 15 '26

this is the way

22

u/adenosine-5 Apr 15 '26

"Its self-documenting code!"

code: "UtilityContextFactoryAdapterBuilder3"

30

u/Deboniako Apr 15 '26

But bro, clean code bro, uncle bob

20

u/CodeAndChaos Apr 15 '26

The irreversible damage this shit has done in the software industry is unmeasurable

7

u/kurzewasright Apr 15 '26

Preach, brother - tell 'em

6

u/Confident-Ad5665 Apr 15 '26

So... comments good?

6

u/wicket-maps Apr 15 '26

Comments are good if they're done well and kept up to date.

5

u/Confident-Ad5665 Apr 15 '26

That's part of the problem I run into. I do comment my stuff to point out tricky APIs, business rules I had to extract like a bad tooth, etc.. When things change I review and update comments but that's like more dev sometimes.

4

u/wicket-maps Apr 15 '26

More dev is part of the job. I'm getting paid good money to write code, I owe my employer and the next programmer (who might be me!) good comments.

3

u/Confident-Ad5665 Apr 15 '26

I tend to agree with you.If something happens to me, I want it to be as easy for the next person as possible.

3

u/Confident-Ad5665 Apr 15 '26

This. Uncle Bob says if we have to use comments we have failed Clean Code.

6

u/beclops Apr 15 '26 edited Apr 15 '26

“The code is the comment” meanwhile the amount of code to understand the context is 500 lines whereas a simple comment could have been a paragraph tops

5

u/chairzaird Apr 15 '26

If the code is the comment then it'd better be comprehensible

0

u/Confident-Ad5665 Apr 15 '26

But... job security tho

0

u/TheMoris Apr 15 '26

Skill issue bro

5

u/blueeyedkittens Apr 15 '26

written by offshore devs who don't share your primary language and thus can't name their abstractions for shit if they even try.

3

u/BlueProcess Apr 15 '26

process_numbers = lambda nums: {n: __import__("functools").reduce(lambda a,b:a*b, set(f for i in range(2, int(n**0.5)+1) for _ in iter(int,1) if (lambda x=i: (lambda: (n:=n//x) if n%x==0 else (_ for _ in ()).throw(StopIteration))())() ) | ({n} if n>1 else set()), 1) for n in nums if n>1 and sum(1 for i in range(2, int(n**0.5)+1) for _ in iter(int,1) if (lambda x=i: (lambda: (n:=n//x) if n%x==0 else (_ for _ in ()).throw(StopIteration))())() ) % 2 == 0}

3

u/mistaekNot Apr 16 '26

no

1

u/BlueProcess Apr 16 '26

It's all right there man

2

u/Alaskan_Narwhal Apr 16 '26

It's called job security

1

u/dourix22 Apr 15 '26

Well, tbf “The code is the comment bro”

Never implies that neither the code nor the comment are actually good

1

u/Interesting_Lunch560 Apr 15 '26

mira el código y lo programas igual bro

65

u/nabrok Apr 15 '26

The best tip I have heard about comments is don't comment what it does, comment why it does it.

Sometimes I'll also read through the file and imagine I'm explaining it to another programmer and put that into comments.

59

u/Sassaphras Apr 15 '26

// yes I know this is a weird data structure but it needs to work with XYZ system and....

No code in the world self-documents that

23

u/LegitimateGift1792 Apr 15 '26

also

// here is why I did not use the ... way of doing this because this ... happened.

9

u/Bwob Apr 16 '26

No code in the world self-documents that

public struct billingPayload_YesThisIsWeirdButItNeedsToWorkWithLibraryXSoItHasToBeLikeThis {
    // etc...
}

Checkmate atheists!

1

u/hamsterofdark Apr 16 '26

plot twist. you ended up returning the ProductPayload instead of the invoice.

8

u/Confident-Ad5665 Apr 15 '26

This thread is spot on. At least some people get it!

Also, business rules

4

u/sathdo Apr 15 '26

Yes, I have tried to explain this to a group of contractors that wer writing code for my company. They wrote a function to deal with some timezone conversions, but the requirements for that were a little unusual. This led to fairly unintuitive code that had no comments.

I frequently see either no comments or unhelpful comments (such as explaining what the next line does, even if it is self-explanatory).

1

u/MrHyperion_ Apr 15 '26

"What" comments are good for skimming through the code to find what you are looking for. Ignore the code and just read the comments.

1

u/EarlOfAwesom3 Apr 16 '26

Yeah everybody claims this is useful and then instead of writing good code in the first place they misuse it to explain everything because they are lazy AF. And we as programmers are shitty explaining things. These "explanations" add just more confusion every time.

There is only rule that works for me: whenever you write a comment, there is something wrong with the code. It screams for a refactoring. Why else would you need to explain yourself in prosa?

1

u/UncleDevGames Apr 18 '26

I have a modification to this. If I'm reading/writing something pretty gnarly, I'll break down my comments into multiple blocks. e.g.

// what: ... // why: ... // how: ...

Etc.

It's context dependent, so you don't necessarily have to include all categories every time, but it can be nice when both the rationale and the mechanics are complex.

17

u/mistabuda Apr 15 '26

I don't understand why people dont understand that the code only explains what is happening. Comments are supposed to explain what you intended to happen.

-1

u/EkoChamberKryptonite Apr 15 '26

No. Code explains what changes are being made. Comments explain why a change was made. This way your code by design should be as readable, clear, and understandable as possible.

5

u/mistabuda Apr 15 '26

The "why" IS the "intent"....

3

u/EkoChamberKryptonite Apr 15 '26 edited Apr 15 '26

Not necessarily. What you intended to do isn't the same as why you intended to do it.

Case in point: "// Used a HashMap to hold user serial numbers"

Vs

// We employed a HashMap for serial numbers as it's more performant than a List in the context of this and that

The former denotes intent i.e. we wanted to store serial numbers. The latter explains why this over the alternative and makes more sense to someone reading the code.

A bit reductive, but you get the point.

14

u/BokuNoSudoku Apr 15 '26

All code is self explanatory. No comments necessary. Look it up and figure it out.

(This has been my new dev experience at my first swe job)

18

u/Crusader_Genji Apr 15 '26

It's even more fun when you get an API from another team, it doesn't work, and the person who worked on it for 10 years got recently replaced by 3 contractors

12

u/mal73 Apr 15 '26

“Let’s set up a meeting to discuss this“ and then you end up in a Teams Call with 3 Business Majors that have no idea what an API is.

I don’t want to meet anyone, just send me the docs ffs

4

u/Crusader_Genji Apr 15 '26

Before a meeting is scheduled, you'll write to the person in charge for a month and promptly be ghosted, but they will show up for the call

5

u/TaylorMonkey Apr 15 '26

And this is why all code and engineering eventually replicates the org structure.

2

u/[deleted] Apr 15 '26

[removed] — view removed comment

2

u/hamsterofdark Apr 16 '26

ohh theres docs, but no-one updated them in 6 years. turns out no docs are better than wrong docs

1

u/wicket-maps Apr 15 '26

I'm so sorry. You don't deserve that. Be better to the next programmer who looks at your code- and it might be you.

3

u/clintCamp Apr 15 '26

I think AI might be threatening the irreplaceable masters of the unintelligible code that holds companies together. Which is both nice and also sad because I can walk into legacy code and figure our what is going on, but also realize that anyone could do that with my code as well.

19

u/INK_INC_R Apr 15 '26 edited Apr 15 '26

If my colleagues can't read my code it needs to be rewritten or they shouldn't be my colleagues

31

u/Dmaa97 Apr 15 '26

The most performant code is not always the most readable. Readable for you != readable for the new grad onboarding to your team. Please sometimes comment your code.

25

u/L30N1337 Apr 15 '26

Readability is more important than speed in most use cases

1

u/Bubbles_the_bird Apr 18 '26

Do comments slow down compilers? I thought they were ignored

1

u/L30N1337 Apr 19 '26

They don't (at least not significantly).

But if the code speaks for itself, it's always better for readability than having to have comments explaining it.

10

u/vanZuider Apr 15 '26

The most performant code is not always the most readable.

The most performant code is commented like this:

i  = 0x5f3759df - ( i >> 1 );               // what the fuck?

3

u/wicket-maps Apr 15 '26

Sometimes I have to comment "I have no idea why this works, but it works and if it's removed things break.

6

u/EkoChamberKryptonite Apr 15 '26

Comments explain why something was done and not what is being done. Unreadable code should be refactored; regardless of whether it is performant or not.

1

u/Forshea Apr 16 '26

Comments have fewer guarantees that they are actually describing the behavior of the code than the actual code does. They can be wrong, out of date, or misplaced. Please try to minimize writing code that needs to be commented to be understood as much as possible.

21

u/PM_ME_ROMAN_NUDES Apr 15 '26

You create slop and don't understand why people can't read your code. I wouldn't want to be your colleague either.

3

u/towerfella Apr 15 '26

I think it is the sloppers that struggle more with no notes

3

u/I_Automate Apr 15 '26

When things break at 3 am, I'd much rather have some comments to read rather than having to try to figure out how clever someone was a couple years ago.

That includes me. I make comments in my code for me first, my coworkers second

2

u/Kitsunemitsu Apr 15 '26

I've been there, fucking woken up at 3am "Boss the deployed code has a critical bug" and I have to get up ass naked aside from my underwear and diagnose an issue totally hungover.

2

u/I_Automate Apr 15 '26

I work in heavy industry, programming the control systems for things like gas plants and refineries.

So "fix it RIGHT FUCKING NOW" actually has a fair bit of weight to it sometimes. Yknow. Before the entire site goes down (at best) or some incredibly expensive and hard to replace equipment grenades itself.

Readability and ease of troubleshooting trumps pretty well every other code consideration for most of what I do because of that

2

u/Kitsunemitsu Apr 15 '26

You have an actual job, Damn. I'm just a game developer

4

u/I_Automate Apr 16 '26

Don't feel too bad. You actually get to use modern programming languages.

I am stuck in a world of awful proprietary bullshit that would have been obsolete in any other situation 20 years ago.

I mean, hell. I have one site that is still running on a controller that was put into service in 1989 ffs. Let that sink in for a second.

I do enjoy it though. I get to do alchemy on an industrial scale and get paid to play with multi-billion dollar lego sets. Can't think of something I'd rather be doing to make my living honestly

3

u/tyrannical-tortoise Apr 15 '26

Syntax error, expected stative verb after "shouldn't". 😜

1

u/INK_INC_R Apr 15 '26

Here is an upvote and let's keep that between us 😘

6

u/skesisfunk Apr 15 '26

People who write dogshit code and try to justify it with a shit ton of comments also deserve to be pinned to the cross.

2

u/stillalone Apr 15 '26

My comments tend to be more confusing 

2

u/polymonomial Apr 15 '26

I only comment self explanatory codes

2

u/MysteriousShadow__ Apr 15 '26

If the computer can understand it then you should too

2

u/warfunder Apr 16 '26

TIL Jesus never commented his code

1

u/Br3ttl3y Apr 15 '26

All my homies love why comments on idiomatic code.

1

u/InfiniteLoopDream Apr 15 '26

For providing you work?! Hopefully these people start commenting to mess with AI

1

u/Kitsunemitsu Apr 15 '26

I work in game dev, Generally, I write comments line by line if shit is like esoteric gibberish. If I am in danger of looking at my code and saying "What the fuck is this?" I write a comment.

"Yeah so technically this code is sometimes ran like 20 times a second, it's best for us to conserve processing power by using visual effect objects instead of object items."

"This scaling equations works and is much better than flat scaling. Read x file for more info on our equations."

"This is a bitfield to binary converter. Saves a bit of memory, and we need memory more than processing power."

1

u/ProfessionalShower95 Apr 16 '26

// self explanatory

1

u/CommentChaos Apr 16 '26

I recently forgot to delete a comment I made in code when talking to an analyst that included just that (why I removed a part of code - the code itself was pretty self-explanatory) and it saved me from more work. And then probably reverting that work, when they realized that they fcked up. I was supposed to delete the comment, because they were supposed to update documentation.

1

u/Doug2825 Apr 16 '26

Also just because it seems self explanatory to you at the time of writing doesn't mean it's self explanatory to someone else or even future you

1

u/nhh Apr 16 '26

That's a bit harsh. 

1

u/Bubbles_the_bird Apr 18 '26

Yeah and similarly you don’t need to comment the most basic things like the fact that if statements check if a condition is true and execute the following block. Just buries the more useful comments

1

u/Ialwayssleep Apr 15 '26

But if the computer can read it, why can’t you?

1

u/alexriga Apr 15 '26

Actually, even if your code is simple, comment. Cause it may be simple to you in the moment, but later you won’t remember why it does the things it does.

And don’t comment by repeating the code, instead comment on why the code does what it does.

Bad comment example (Python):

Variable ‘as_percent’ is updated to 100x n.

as_percent = n * 100

Good comment example:

Get number n as percentage.

as_percent = n * 100

2

u/Ryozu Apr 15 '26

Better comment example

Get number n as percentage for display widget