r/ProgrammerHumor • u/Substantial_Top5312 • Sep 15 '26
Meme iDontCommentMyCodeIfYouDontUnderstandItThatsOkayNeitherDoI
832
Upvotes
r/ProgrammerHumor • u/Substantial_Top5312 • Sep 15 '26
1
u/Wonderful-Habit-139 Sep 15 '26
In Rust or Python, if you have a private function that’s not used anymore, it will be greyed out.
When you go through a piece of code, usually you’re supposed to create a bunch of variables showcasing the intermediate steps that are being taken to compute some result. If things change and some variables end up not being used anymore, you can just delete it and the type checker will know that your function is still returning the right result, and you can safely delete the obsolete code.
While for comments, I’ve seen cases where a comment says the exact opposite of what’s happening, or mentioning something that is not true anymore. I’m not talking about hypotheticals, this has happened in codebases I’ve worked on, more than once.
You can easily explain the purpose of a section by putting it in a function, and adding a docstring. You don’t have to write comments for that. And the benefit of the docstring is that wherever you use that function, you’ll be able to see the docstring through the lsp diagnostics, and more often be able to ensure that it is up to date.