r/ProgrammerHumor • u/Substantial_Top5312 • Sep 15 '26
Meme iDontCommentMyCodeIfYouDontUnderstandItThatsOkayNeitherDoI
832
Upvotes
r/ProgrammerHumor • u/Substantial_Top5312 • Sep 15 '26
427
u/GabuEx Sep 15 '26
Left: "I'll comment to say how my code works."
Middle: "You don't need to do that! Code should be self-documenting!"
Right: "I'll comment to say why my code does this."
60
u/everypowerranger Sep 15 '26
I'm not writing comments for you, I'm writing them for me.
65
u/anoppinionatedbunny Sep 15 '26
what a terrible way to misinterpret "good code should be self-commenting"
15
u/icecream_specialist Sep 15 '26
This except the guys on the ends are "too lazy for comments/docs"
11
u/Interesting_Play_578 Sep 15 '26
--Don't remember what this section does but the app crashes without it
11
u/traplords8n Sep 15 '26
Dude I learned in the first 3 months on the job that I will forget every little thing about code I've moved on from & have to go back to later on.
8
u/Apprehensive_Bit7392 Sep 15 '26
The bit the self-documenting crowd skips: a name can say what the code does, it can't say what you deliberately didn't do. There's no function name for "we don't cache here because the invalidation was worse than the lookup". That only fits in a comment.
6
u/itgforlife Sep 15 '26 edited Sep 15 '26
I typically just add comments when something is external to the code, unintuitive, or could seemingly make no sense. e.g.
// https certificates required when using Playwright with webkit.or// csp can be validated here {link1} and here {link2}In vscode, you can also link to files and line numbers with certain commands. So sometimes I'll put those in comments as well.
6
u/PerfectSituation1668 Sep 15 '26
You should not delete this part, this somehow breaks everything. I tried to find out why, but it does no harm, so I'm just leaving it in.
14
u/NoHurry28 Sep 15 '26
It's well known that there is literally no other way to tell what functions do unless they're commented
5
u/Wentyliasz Sep 15 '26
4
u/CptGia Sep 15 '26
Middle one would read "if you don't understand I'M bad at coding"
4
u/ReefayToo Sep 15 '26
I guess I'm the guy on right. Or most likely left. I like to comment 🤷♂️
4
u/Puzzleheaded-Weird66 Sep 15 '26
I comment it after coming back to the same code twice where I get confused
4
u/scheimong Sep 15 '26
Funnily enough you can put "my code doesn't need comments" on the two sides and the meme still works.
3
u/GnarlyNarwhalNoms Sep 15 '26
Thank you for using this format correctly. Lately, I've been seeing a bunch of different memes with this template that have three completely different captions, and it's been driving me nuts.
3
u/NewArborist64 Sep 15 '26
Try going back and trying to fix old code, cursing out the programmer whose comments weren't clear... And then realizing that this was code you wrote 20 years ago
3
u/brahmastra596 Sep 15 '26
You should see the number of AI slop comments I see while reviewing PRs.
3
u/Cephell Sep 15 '26
It helps to realize that comments are always ALWAYS for other people. Sometimes that other people includes you in the future.
3
u/PatinhoGamer Sep 15 '26
I am commenting the code if it does something that is counter intuitive explaining why we do it that way
3
u/gareewong Sep 15 '26
Comment "why" not "what", that is all you need to do if it is not obvious.
3
u/SpeedLight1221 Sep 15 '26
I comment so the next person that works on it who will see the code for the first time can understand it faster.
i don't collaborate with anyone. the next person is me the day after. I just blank out on it completely every time i look away. its a problem, help
5
u/AcanthisittaKooky987 Sep 15 '26
the problem with comments is sometimes the code drifts from the comment - you can never trust them so you just read the code either way anyway
2
u/nicman24 Sep 15 '26
The only comments that I feel make sense are bit magic or regex fuckery.
2
u/ForgedIronMadeIt Sep 15 '26
2
u/Fadamaka Sep 15 '26
I think this should be reversed.
2
u/mixxituk Sep 15 '26
meanwhile my methods names are 500 characters long
2
u/Nach0z Sep 15 '26
All code is self documenting. The code tells you exactly what it does. But the code can't tell you what the writer INTENDED for the code to do. Document your code so people can find where you fucked up in the future.
1
u/ObjectsCountries Sep 15 '26
alternatively, the middle uses javadoc/docstrings/etc. while the lower and upper ends use multiline comments
1
u/Forsaken_Celery8197 Sep 15 '26
What's worse: no comments or out of date/not accurate/misleading comments?
1
u/McSand_boi Sep 15 '26
I'm in between the center and right of the graph. I'm just really fucking lazy but I do know that saying what the code does is invaluable.
1
u/TreetHoown Sep 15 '26
If you don't understand, I wrote my code in a bad way*
1
u/MuslinBagger Sep 15 '26
OP's comments: here we are adding 1 and 2
1
u/PuzzleMeDo Sep 15 '26
"I'll avoid commenting my code, because frequent comments make it look AI-generated."
1
u/chiqu3n Sep 15 '26
1
u/ExtraTNT Sep 15 '26
Good code reads well, no need to document a lambda adding +1 to a number.
Doc exceptions, architectural choices or user facing functions in your libs.
No doc is better, than outdated doc
1
u/Unique-Rate2225 Sep 15 '26
Claude, could you please kindly explain what does to code do between line 1 and 15000?
1
u/MissMormie Sep 15 '26
And then there is claude who'll write a whole novel.
1
u/CucumberBoy00 Sep 15 '26
I'm sure I've seen the reverse of this meme here before
1
u/EskilPotet Sep 15 '26
When I code assembly I have more comments than I have code
1
u/Roppano Sep 15 '26
95% of the time I get the urge to write a comment, I can make my code even better by naming my methods better, or extract parts of my method to different methods and naming that properly (even though, I find this to be a red flag to investigate)
1
u/Professional_Top8485 Sep 15 '26
Code should be self documenting because it's source of truth. Usually is just laziness not to do so, easier and more effective to just put comment and get done with it.
I am just somewhat asshole and not get paid too much, so meh.
1
u/BorderKeeper Sep 15 '26
As a soft. engineer of 11 years why are people so adamant with comments. Everywhere I work comments are seen as laziness to have your code be self-documenting at worst, and a potential divergence between what the code does and what the comment say over time at best.
Even people who rely on AI a lot are stating that AI uses comments as excuses to do hacks (which is maybe what the training data taught it to do) and if you force it to not do comments it thinks about the code instead of a sweet sounding comment on why what it did is right. (in my own team we noticed it sometimes forgets to update comments and just changes the code so AI makes same mistakes as people do)
Me personally I see a comment as a code smell. The engineer looked at his creation and was worried people will be confused by reading it. Sure sometimes that has it's place like necessary hacks, or weird counter-intuitive APIs, or just being pressured to write something weird and unexpected, but most of the time it's:
Also for everyone I am not against documentation in the form of code comments. Those are awesome, stick them as headers above functions, classes, and interfaces and the IDE will even parse it and show your docs when you higlight a function. What I am talking about is inline code explaining inner workings of functions and classes.
1
u/thebobest Sep 15 '26
I don't comment my code, i document it with .md files🗿
1
u/NotInMoodThinkOfName Sep 15 '26
Doesn't make a sense to comment every method. If proper code they are short and read as fast as a comment. Just comment not obvious things. Rather like to comment about the class.
1
u/JacobStyle Sep 15 '26
I do a lot of automation stuff. Nothing is "self documenting" once it's built to account for a gazillion little weird edge cases that occur in whatever third party software/environments/APIs/websites I'm working with. No way is that going to be readable without comments that look like this:
//Sometimes the save button doesn't load right after saving. Detect bad save buttons and refresh the screen before making more changes1
u/clauEB Sep 15 '26
I worked with one of the people that wrote the original Postres implementation out of Berkeley. He insisted each line of code needed a line of comments.
1
u/Massepunkt_m1 Sep 15 '26
I don't even understand my own code three minutes after writing it, how is anyone else supposed to know what the hell I was up to?
1
u/AceBean27 Sep 15 '26
Comments are for explaining bad business logic, not bad code.
1
u/ZunoJ Sep 15 '26
Business logic needs comments and if others don't understand the technical aspects of my code, it is not them who are bad at coding but me. The right choice of abstractions and patterns should make it dead simple to read the code
1
u/stojanbrajovic Sep 15 '26
// filters points
const filteredPoints = ...
1
u/XxDarkSasuke69xX Sep 15 '26
I don't comment because : 1. I don't even know what I'm doing. Or 2. If I know what I'm doing, then there is no chance of another programmer to not know what the code means.
1
u/perringaiden Sep 15 '26
I leave enough comments that I can come back in two years, and understand how stupid my decisions were.
1
u/nwbrown Sep 15 '26
No meme format had been abused as much as this one.
1
u/WormsDelicious286 Sep 15 '26
"Self-documenting" code is the barest of minimums for making sure your code isn't bad. It's literally the lowest acceptable standard, a kind of Federal minimum wage code. Even AI writes better code than that.
If you think the entirety of the useful metadata about the code can be expressed merely as function and variable names, you might actually be on the left of this diagram.
1
u/GenericFatGuy Sep 15 '26
I'll comment my code in places where self documenting isn't feasible.
1
u/urbaum Sep 15 '26
Clean code is a scam
1
u/Ilirian Sep 15 '26
also Claude: I'll comment your comment
1
u/Drugbird Sep 15 '26
The best "comments" are function names, variable names and tests.
1
u/jmflyers Sep 15 '26
time to change the peak to 'I don't need to comment, Claude does it for me'
1
u/MyPasswordIsIceCream Sep 15 '26
Or you could use strongly typed languages, name your variables and functions properly and write descriptive commit messages. Comments should be exception, not the rule.
1
u/TurdOfChaos Sep 15 '26
I don’t think one statement necessarily excludes the other.
There is value in understanding the concept of “self-documenting code” , and striving to write code that way.
Commenting should never be there as a crutch that compensates for bad code readability. Private methods, single responsibility principle, unit tests, all of it among many other concepts can accomplish legible , elegant and self-explanatory code.
However, it should not be taken to the extreme where every comment is immediately bad, there are scenarios where a comment adds info that cant be conveyed by code.
Now with AI , I think this paradigm will change though, it will probably at one point start becoming beneficial to write purely AI generated code because it’s safe to assume AI is best at reading it.
1
u/enigma_0Z Sep 16 '26
My general rule is if a thing takes longer than 2m to read and understand intrinsically, it’s either poorly written, in need of a comment, or both.
I still have battle scars from reading groovy pipelines and react code, both of which stacked 10s of ternary operators and spending a literal full workday trying to untangle what some code was doing.
1
u/Square_Ferret_6397 Sep 16 '26
It's more like Left: no comments, big nested for loops and if statements, names variables a, b, c, x, y, i, j Middle: same as left but with comments explaining everything Right: give variables more descriptive names and separates code into more methods thus leaving less comments
1
u/timtucker_com Sep 16 '26
I'm a big fan of "comment driven development" as a lighter weight alternative to practices like test driven development.
Any time that I'm in a situation where requirements are being discussed, I'll start creating high level functions / components and writing out comments as notes as a precursor to fleshing out implementation.
Overall speed to get things done is faster than trying to take notes in something outside an IDE and the approach translates really well to delegating work or handing off tasks to AI agents.
1
u/p1neapple_1n_my_ass Sep 16 '26
I also comment my code because I don't want to delete it yet.
1
u/Grouchy_Exit_3058 Sep 16 '26
After going back to a 2 year old project, I realized how useless or useful some comments are.
1
u/Luzzgar Sep 16 '26
I can workout what it does, but please write down why you did it that way.
1
u/ArgueLater Sep 21 '26
I have tags for my comments, and stick to them. Basically a bunch of labels for the different types of "gotchas" that exist, labeling code that works in strange ways but kind of has to.
1
u/shin_chan444 Sep 21 '26
Use gdb
1
u/dracorotor1 Sep 15 '26
Before the New Great Dying took them away and replaced them all with AI, I was leading a team of UX guys and had a reputation for being too lenient for my own good, but I always put my foot down about not commenting on code.
I’m not paid enough to be comparing 300 lines of JavaScript if statements in last month’s backup to the current version, just to find your edit that broke the display, and then have to figure out why you did it.
Comments cut a 3 hour job down to a 30 minute one, and I expect to revisit any block of code at least 4-5 times in the lifetime of the page, so just accept that showing your work is not a weakness, prep for an extra hour of time on any new project, and save us 2 or more workdays of wasted effort in the future.
0
u/Tupcek Sep 15 '26
in this day and age of AI, this is no longer valid discussion. Who writes code line by line nowadays? And AI documents everything
0
u/RRumpleTeazzer Sep 15 '26
does the comment apply to the code on the line, the line below, in the same block, the next block ?
the truth is, comments should be scoped for what they apply to. but it doesn't, since plain textfiles don't support it.
0
u/GoogleIsYourFrenemy Sep 15 '26
lol you're all still righting code. I have the AI write the comments and the code.
0
u/ZZerker Sep 15 '26
Comments are useless and i wont change my mind.
Best comment I ever had was in japanse kanji signs and when translated was: "main method"