http://www.perlmonks.org?node_id=879621


in reply to Re^6: On comments
in thread On comments

However, I don't see how using a higher-level language rather than English prose would help in every case.

Definitely not "in every case". And to be honest, these days I'd use a good macro assembler (directives .while etc.) to code most loops, branches and procedures, which does away with the need for the HLL "description". But back then, the assembler did little more than translate the opcode mnemonics to binary, and perform (non-nested) branch calculations.

Your 'security reasons' is an example(*) of when you should (ie. I would) justify breaking my basic "Don't comment." stance. It is a clear case of the exception that proves the rule.

My "Don't comment" stance has a similar power to simplify and clarify, as modern moves in governments to switch from 'Everything is secret unless we say it is not' to 'Nothing is secret unless we say it is'. There is no intention to endanger people or things by giving away everything.

Just a desire to ensure that (costly) security efforts to be concentrated upon those things that need it. Oh, and if by-the-by, it prevents a few politicians and civil servants from hiding their laziness, gross incompetence or worse, behind layers of "need to know", so much the better.

And that's my take on comments. If you've justified the addition of a comment in a piece of otherwise sparingly commented code, you can bet your bottom dollar I am going to give it my full attention.

But by my reckoning, there are about 7 or 8 significant comments in this, but I challenge anyone to find them in a hurry, so lost are they in a morass of unnecessary, irrelevant or downright misleading thoughts, feelings, opinions and speculations.

(*)It is hard to tell from such a brief description of a real situation, but I actually, I still might not comment it. From my interpretation of your description, I would probably opt for self-documentation in the form of a macro: Say SEC_reg-zero <reg>; or SEC_reg-signExtend <reg>; and the detail of the security implications would be detailed once in the macro definition.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^8: On comments
by Your Mother (Archbishop) on Dec 29, 2010 at 17:36 UTC
    If you've justified the addition of a comment in a piece of otherwise sparingly commented code, you can bet your bottom dollar I am going to give it my full attention.

    ++ Increasing verbosity --> decreasing attention.

      ++ Increasing verbosity --> decreasing attention.
      Yeah, that's why you should always golf your production code, then it gets the most attention from the person maintaining it.

        We were discussing plain English comments (or whatever local lingo). I suppose if I had written 10 paragraphs explaining that, you wouldn't have bothered reading it and therefore wouldn't have replied. Next time I'll know better.