Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This is not convincing to me because the examples are trivial:

    -- swap the elements of a pair
    swap :: (a,b) -> (b,a)
Yes this is redundant.

    let b=a+1   -- add one to 'a'
Yes this is also redundant

Does it mean that every piece of code can be expressed as clearly as in a one-line comment in natural language? I don't think so.



The argument is not to never use comments, but rather to avoid bad comments.


I realize this, but the article doesn't provide any clear definition of what actually is a bad comment. It only gives trivial examples of bad comments such as "increment a by one".

Since I don't think anyone here would argue that "increment a by one" is a useful comment, the part about duplicate/obvious comments isn't adding much to the discussion about the usefulness of comments.

Nevertheless, it's true that comments cannot be checked by the compiler, and that's a more interesting point, I think.


I have never seen comments like these except during arguments that good code doesn't need comments.


But you see, nobody on the internet has ever offered up examples of good comments before, at least that I can find. So if you say these comments are bad, but there exists good comments, why not provide examples of good comments to make your argument stronger?


What about the Code Complete examples posted somewhere on this thread? ("above", at the moment)?

What about checkable specifications together with a comment explaining the formula, particularly for anything with a nice physical intuition? This kind-of addresses the out-of-date comment problem.

Another example which came to mind is a Lamport comment about some sort of layout-related thing, I can't remember specifics. The comment gives a really good intuitive feel for why his code produces a nice-looking layout. Without the physical intuition provided by the comment, the code is pretty difficult to grok. I can't find it, so I really hope I'm not making this up...

edit: 2nd par




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: