[Tutor] Simplicity vs. Speed

Roeland Rengelink r.b.rigilink@chello.nl
Tue, 15 May 2001 19:45:24 +0200


alan.gauld@bt.com wrote:
> 
> > Especially since simplest is usually also fastest.
> 
> Sorry I've got to disagree with that one. Simple algorithms are
> often fast enough but they are rarely optimal. (Consider bubble
> sort, or the shuffle discussion recently). So keep it simple
> by all means but better(ie faster!) algorithms usually carry
> the cost of increased complexity...
> 

Hmm,

I thought about this a bit.

First, you are of course right. My statement was a one sentence
assertion about programming in general. I would say that any meaningful
one-sentence assertion about a sufficiently complicated subject is
either tautological or hogwash.
This one wasn't tautological.

Having said that, I was thinking more about program units (modules,
classes) that perform several functions than about algorithms that
perform one function. 

However, the context was optimization, which is an algorithm issue. And
you are right the fastest algorithm is not necessarily the simplest.
Moreover, even the fastest algorithm can often be made faster by
special-casing, at even more cost to simplicity.

> Everything else in your post I agree with BTW. Especially the
> 3 way categorisation of slowness.
> 
> Alan g.

Roeland

-- 
r.b.rigilink@chello.nl

"Half of what I say is nonsense. Unfortunately I don't know which half"