Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[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" <[email protected]>
To   <[email protected]>
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: [email protected]
[mailto:[email protected]] On Behalf Of Clyde Schechter
Sent: Mittwoch, 28. April 2010 20:10
To: [email protected]
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: [email protected]




*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index