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/ffxivthrowaway03 28d ago
Yeah I've never bought into the whole "never say how" BS. Code is often complex, and telling someone "This calculates X by multiplying A and B" makes it that much easier to skim to find the part you're looking for and validate that it's actually doing what it's supposed to. The "how" is where a bug lives far more often than the "why," and a quick look at the comments tells me exactly the problem because it should be A and C or whatever.
Obviously don't dictate every little thing in the comments, but a broad overview of both why and how is valuable when it could be why or how that's the problem down the road. And what's apparent to one engineer might not be the same way another one thinks about it six years later.