Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: RE: "doing anything the quickest way does no harm"


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: "doing anything the quickest way does no harm"
Date   Wed, 28 Apr 2010 23:50:13 +0200

<>

O boy! I hope that this did not spoil your day, Clyde. _All_ of this grew
out of my knee-jerk reaction to the fact that I had _suggested_ -count- as
early as this post
<http://www.stata.com/statalist/archive/2010-04/msg01532.html> and all of a
sudden we were talking -summarize-
<http://www.stata.com/statalist/archive/2010-04/msg01542.html> in the
"Overriding a loop if 0 observations using tabstat" thread. So I queried
Nick about the true causes of his preference for -count- expressed in the
very last line of
<http://www.stata.com/statalist/archive/2010-04/msg01552.html> and, in the
blink of an eye, this topic took on a life of its own. So, to emphasize what
Nick has already said, he did express a preference for -count-, which seems
to accord with yours.


HTH
Martin

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Clyde Schechter
Sent: Mittwoch, 28. April 2010 20:10
To: statalist@hsphsun2.harvard.edu
Subject: st: "doing anything the quickest way does no harm"

<>

Perhaps I am just a superennuated, grouchy programmer who suffered through
the spaghetti code era of the 1960's and 1970's, still fighting the last
war. But I take issue with the statement "doing anything the quickest way
does no harm."

I think there is a strong consensus in the field of computer programming
that clear, transparent code generally trumps speed gains accomplished
through obscure tweaks because, in the long run, being able to read and
easily maintain your code saves more time; and the human time so saved is
more valuable than the computer time salvaged.  I think there is also
consensus that if your program really runs too slowly, you are usually
better off substituting a faster algorithm (e.g., use binary table
searches instead of linear ones), or moving to faster hardware.  You will
probably get greater time savings those ways than by squeezing out a few
microseconds here and there with opaque tricks.  And when you come back to
your code later, you'll understand what you did.

Now, in the particular thread that led to this quote, these considerations
point in the same direction.  Using -count-, when what you want is a count
and not other descriptive statistics, is better than using summarize
because it's more transparent: it means what it says.  Even if -count-
were slower than -summarize-, I would still use -count- there!  In the
rare event that one really needs to squeeze out a little extra time by
using an opaque command, at least one should put some comments in the code
explaining what's going on.

I suppose I would have passed this over without comment were it not for
the fact that it came up on the same day (I read statalist-digest) when
somebody suggested using a global macro--a device that is potentially
dangerous and should be used very, very sparingly.

End of rant.

Clyde Schechter, MA MD
Associate Professor of Family & Social Medicine
Albert Einstein College of Medicine, Bronx, NY, USA

Please note new e-mail address: clyde.schechter@einstein.yu.edu




*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index