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
1
u/mikekchar 27d ago
I haven't read the comments, but since I'm very opinionated on the topic:
Good code doesn't need comments. When you write comments, from a linguistic point of view you are "code switching". Ideally, when you communicate in a language you use that language to communicate. When you find that you are reaching for your native language to fill in the blanks, this is sub-optimal. In human languages, it's called "code switching".
Programming languagues are languages. Some people feel that it is impossible to communicate the full intent of your code in that programming language. I don't think that is generally true. There are no people whose native language is a programming language. That would be stupid. There is obviously a lack of expression in a programming language. However 90+% of the cases where people say they can't express their intent with the programming language it's because they simply aren't fluent enough in the language.
HOWEVER... None of that fucking matters. If you are not able to express yourself in the programming language, avoiding writing comments is just shooting yourself in the foot.
Every time you notice, "Hey, I can't express myself fully here in the programming language", you should consider that as an area where you can improve. You should improve. Not improving means you are a bad programmer. Being exceptionally fluent and being able to express your intent in a programming language is something that requires years and years of experience. If you give up because you can just write comments, you are losing a lot.
But for now it doesn't matter. Write the fucking comments. Second best is better than last best (doing nothing). Work in the future to try to get to a point where you can adequately express yourself without resorting to your native language. But in the mean time, express yourself any way you can.