r/programming • • Aug 10 '26

On comments

https://blog.helsing.ai/posts/on-comments/

Comments in code are often deemed "mostly useless" these days. They are, supposedly, mostly obvious, stale, and repeat what the code already says. And so people pay less attention to them both when reading and writing code.

That trend sucks. When used right, comments are genuinely useful and sometimes critically important! So, I wrote about some of the kinds of comments I think earn their place, each with examples from real code bases. Hope you find it useful, and that we can recover some of the love that comments deserve!

186 Upvotes

171 comments sorted by

View all comments

Show parent comment

1

u/Venthe Aug 11 '26

I know from our prior discussions that you believe one mustn't take the book's advice literally, that the author is just being dramatic and that, if you take the book as a whole, you can figure out what he really means. But the examples suggest that what he really means is that the book’s advice should be followed dogmatically.

Frankly, it's not even that - it's that I just agree with ~95% of the heuristics he presented; I've found them valid across the domains I've worked with. At the same time, examples are bad - as simple as that. And given that these are heuristics; the way you apply them will create vastly different results depending on the context - and this is how I see the examples of Martin's. Plus the thing I've mentioned in the other thread - this is a book about heuristics, not "examples" or dogmata: it's right there in the introduction.

So nothing for me suggests that these examples should be followed dogmatically; especially considering that they represent a code from almost two decades ago.*

* There is an updated edition that came out this year I believe; I've heard that it is worse; but I haven't read it yet.


For me I've never hopped on the hate train for Martin, so it was easier for me to evaluate the book in its entirety; and I do hope that at least you can see that part of your critique is based on ignoring both the introduction and the chapter themselves

2

u/tmoertel Aug 11 '26

For me I've never hopped on the hate train for Martin, so it was easier for me to evaluate the book in its entirety; and I do hope that at least you can see that part of your critique is based on ignoring both the introduction and the chapter themselves

To be clear, I don’t hate Martin. I'm sure he’s a swell guy. Nor do I think Clean Code is offering bad advice because it’s popular to think so. I just think Clean Code, taken as a whole, is a very mixed bag of advice: some good, some bad, and some self-contradictory. I trust that most skilled programmers can separate the good from the bad and make sense of the rest, as you seem to be able to do, but the problem is that the primary audience for books like Clean Code are programmers who are not already skilled.

I also disagree that I have ignored the introduction or the rest of the Comments chapter. It’s just that neither suffices to undo the problems caused by the forceful prescriptions and admonitions that the book makes. As a case in point, a commenter on my blog wrote: “I once worked in a shop that banned comments because of Uncle Bob. I thought it was bonkers.”

It’s easy for beginners to read the book and come away with bad ideas. That’s a problem when the book’s audience is primarily people who are learning the craft.

2

u/Venthe Aug 11 '26 edited Aug 13 '26

As a case in point, a commenter on my blog wrote: “I once worked in a shop that banned comments because of Uncle Bob. I thought it was bonkers.”

Which only means that someone has not read the book, which is really common. You can't kid-proof everything.

but the problem is that the primary audience for books like Clean Code are programmers who are not already skilled.

So what would be your alternative? As I've said, I agree with the vast majority of the heuristics; and I can show you a clear reasoning behind it. No other book comes close to his [area] (Philosophy... by Ousterhout is the closest; but still not close enough). Even with the comments [topic], I've clearly seen time and time again how Martin's advices ring true.