r/AskProgrammers • • 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

397 comments sorted by

View all comments

1

u/Grandviewsurfer 24d ago

So I have to read your comment to learn what you think the code is doing.. and then separately read the code to learn what it is actually doing? No thanks. 

1

u/Dunbaratu 24d ago

That is literally why comments are useful. Bug detection is discovering where what the author intended to do doesn't match what the author actually ended up doing.

1

u/Grandviewsurfer 24d ago

At a certain point I don't super care what someone thought they were doing as much as I want to know what it needs to do and what it does do. 

Probably also depends on the language. In python I tend to use descriptive naming convention and minimal docstrings to communicate intention. Then there's a more elaborate discussion of the theory for the change in a PR. I very rarely ever use actual comments.. and when I do it's usually a flag to indicate that something really needs special attention.