Bookmark and Share

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

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

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

From   "Clyde Schechter" <>
Subject   st: "doing anything the quickest way does no harm"
Date   Wed, 28 Apr 2010 11:10:05 -0700


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:

*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index