Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Documenting ssc contributions: efficiency for Man and machine

From (William Gould, Stata)
Subject   Re: st: Documenting ssc contributions: efficiency for Man and machine
Date   Mon, 19 Jan 2004 10:23:07 -0600

R. Allan Reese <> worries that comments interspersed in 
code might cause Stata execute the code more slowly, 

> [especially] if to slow down if comments are included in, say, an inner
> loop.
Allan is so concerned about ths potential problem he is even thinking about 
submitting two versions to SSC, one with, and one without comments!

That will not be necessary.  When Stata reads ado-files from disk into memory,
Stata does not store the comments.  Allan is right that comments would cause
an intepretive language to slow down.  Stata strips the comments for Allan.

The only cost to comments is the time it takes Stata to read them from disk
and discard them, which is not much.  If, however, Allan feels obligated to
write an essay (which I sometimes do), I suggest he go to the bottom of the
file, add an -exit-, and then write away.  That will keep Stata from even
having to read the lines.

By the way, Allan also wrote, 

> It was recently reported on this list that Bill Gould thinks that programs
> should not need comments.

That is not my position, although it is quite possible that I said the above
because, to make a point, I have been known to exaggerate.  My position is
that good variable names and clean style make unnecessary many comments, and
too many comments that I see repeat exactly what the code already says.

          se = result       /* assign result to se */

A good cooment adds information not shown, or often hidden, in the code.

-- Bill
*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index