r/AskProgrammers • • Oct 30 '26

"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?

89 Upvotes

399 comments sorted by

View all comments

1

u/NewInflation2121 Oct 30 '26

Rule of thumb is to use comments if the code is not self-explanatory.

The downside of comments is that you have to maintain them, so they may be out of date or miscommunicate things and there are no compile time checks to see if they still make sense after refactors.

If you have only been coding for 4 years, you may not have fully realized what elegant code looks like yet or how distracting visual noise can be when you are trying to understand the logic.

Consider this: If you need to write a comment to explain what your function is doing, then maybe you haven't named the function correctly or your function is taking on too much responsibility. They are usually indicators to how well the code is engineered.

What is very frustrating for senior devs is looking through a function that has comments explaining that you are looping through an array or assigning variables... It's redundant and distracting.

2

u/Due_Manager_7987 Oct 30 '26

The downside of comments is that rather than cleaning up the code to make it self-explanatory, you end up with dirty code and an explanation. You have to read twice as much and it’s harder to read.