In defense of slow code, was Re: [lug] File modification
Scott A. Herod
herod at interact-tv.com
Thu Mar 14 08:31:14 MST 2002
I consider myself a reasonably good programmer even if my only
course in it involved writing FORTRAN 66 on punch cards. ( Us
old people always have to say something like that. ) I confess
that I have written, even recently, code that on the first pass
was v e r y slow. The crime in industry is to let the customer
see any of it.
For an example from a few years ago, I recall implementing something
in Mathematica that recreated the basis functions for a wavelet
basis described in Ingrid Daubechies original paper. I started it
running on a Sun 350 and came back a few hours later to find it
still going. After some tests, I determined that it would still
be running, finishing sometime in 2007.
I think that it is a completely reasonable exercise to begin
to numerically compute discrete Fourier transforms by writing an
integrator and start looping through sines and cosines. If for no
other reason, it makes one appreciate the ingenuity of the FFT.
Of course, when you provide the code to your client, you had better
have researched good algorithms a bit.
BTW, my recent example is pretty close to Bear's file opening and
closing. I had been using a XML DOM structure to do data look-up.
My code consisted of several queries against the DOM structure. Not
enough in my opinion to necessitate sorting first. After demonstrating
this to a client, they asked if I could add a reasonably deep
hierarchical search. I of course said yes and built it into my
existing structure. It worked, and I demo'ed it for them, but it's
was pretty slow. I spent a couple of weekends writing something
to pre-process the database before I released the code to them.
More information about the LUG