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   Nick Winter <[email protected]>
To   [email protected]
Subject   Re: st: Documenting ssc contributions: efficiency for Man and machine
Date   Tue, 20 Jan 2004 09:16:44 -0500


As a quick test, I just ran two programs -fastversion-, which simply counts to 1,000,000 in a -forval- loop, and -slowversion-, which does so, but with 200 lines of comments within the loop. (Neither does anything substantive.)

I was able to detect *no* difference in execution speed between the versions. So my guess is that removing comments from .ado files will have no appreciable impact on execution speed.

--Nick Winter

At 03:05 PM 1/19/2004 +0000, you wrote:

It was recently reported on this list that Bill Gould thinks that programs
should not need comments.  I disagree; it's often hard to remember why a
particular line/variable/condition was needed when reading code written
some months back.  Too much computing (eg APL, web-authoring, anything by
** Corp) is write-only code.

On the other hand, for an interpreted language there may be a noticeable
hit on performance if comments are included in, say, an inner loop.

I'm on the verge of contributing to SSC, and thought it would be
worthwhile packaging two versions of the main routine.  The *.ado file
should be stripped down to plain code and all comments removed.  The
second version is the same code but with all the development comments
revised and expanded, to be readable.  This is a nod towards the advice of
Don Knuth (quoting informally from memory), that a program should have the
form of paragraphs with an introduction for humans and then code for
execution.

One question is whether other people do this, and if there is any
convention for the extension code for documented code: if not, .doc or
.com are possible but clash with other uses; .CDO could suggest Commented
DO.

R. Allan Reese                       Email:     [email protected]

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
--------------------------------------------------------
Nicholas Winter 607.255.8819 t
Assistant Professor 607.255.4530 f
Department of Government [email protected] e
308 White Hall falcon.arts.cornell.edu/nw53 w
Cornell University
Ithaca, NY 14853-7901

*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/




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