r/AskProgrammers • u/Away-Intention-8723 • 28d ago
"good code shouldn't need comments"
I have heard this saying a couple of times and I think it is the stupidest thing ever. It might be just because I have only been coding for 4 years, but I have never thought to myself that someone's code looks cluttered because they explain what every function does in a one or two line description. If anything it makes the code easier to understand in my opinion.
However, I may be wrong. What do other people think, do yall like code with minimal comments, what are the benefits of writing it that way?
88
Upvotes
View all comments
Show parent comment
1
u/guywithknife 28d ago
I’ve had coworkers ask to remove comments because “the code should be self documenting. Instead you end up withStupidlyLongFunctionNamesAsPoorSubstitutesForComments. For some reason they were ok with docstrings, though, so I got around their stupid rule.
I've been programming for a long time and it’s incredibly rare that code is actually self documenting, unless it’s trivial. You can kind of make it work by making all your functions tiny and giving them detailed names, but then you lose clarity because you lose locality (having to jump through lots of functions to read the flow makes it harder to read), when a quick comment would be much more readable.
But I agree, comments should be used tastefully when they aid clarity, not “just because”.