Comments are a failure

The book that most changed my view on comments in code is Clean Code: A Handbook of Agile Software Craftsmanship by Robert Martin.  There's an entire chapter of the book devoted to comments.  In it, Martin says the following:

Nothing can be quite so helpful as a well-placed comment.  Nothing can clutter up a module more than frivolous dogmatic comments.  Nothing can be quite so damaging as an old crufty comment that propagates lies and misinformation.

Comments are not like Schindler's List.  They are not "pure good."  Indeed, comments are, at best, a necessary evil.  If our programming languages were expressive enough, or if we had the talent to subtly wield those languages to express our intent, we would not need comments very much -- perhaps not at all.

The proper use of comments is to compensate for our failure to express ourself in code.  Note that I used the word failure.  I meant it.  Comments are always failures.  We must have them because we cannot always figure out how to express ourselves without them, but their use is not a cause for celebration.

So when you find yourself in a position where you need to write a comment, think it through and see whether there isn't some way to turn the tables and express yourself in code.  Every time you express yourself in code, you should pat yourself on the back.  Every time you write a comment, you should grimace and feel the failure of your ability of expression.