sorting algorithms

Andrew P. Mullhaupt amull at Morgan.COM
Mon Nov 20 07:34:26 AEST 1989


In article <1989Nov17.185514.15726 at algor2.algorists.com>, jeffrey at algor2.algorists.com (Jeffrey Kegler) writes:
> In article <6916 at ficc.uu.net> peter at ficc.uu.net (Peter da Silva) writes:
> >I like Horowitz and Sahni, "Fundamentals of Computer Algorithms". They're
> >a lot more readable than Knuth, and use a high-level pseudocode for
> >everything. (whatever posessed Knuth to express algorithms in assembly?)
> 
> It is important to remember that Knuth's sorting book is over 15 years
> old in a field that moves very quickly.  In particular, the decision
> to use assembly, while by current standards, very ill-advised, looked
> better then.  C use was not then widespead (the UNIX kernel had just
> been rewritten in C from assembler), so what was Knuth to do?  Use
> FORTRAN?  ALGOL?  Either probably would have been better, actually,
> than MIX, but at least you can see that Knuth's choice was a rational
> one at the time.
It would be wishful thinking to expect that had Knuth chosen ALGOL, the
state of computer science would be better, but that was the acceptable choice
at the time. The pseudocode in the literature at the time, and to a
great extent still today, is much more ALGOL-like than C is. Your
preferred choice (Horowitz and Sahni) is quite good, but an order of 
magnitude less comprehensive than Knuth. Your preference is a bit odd
since SPARKS, the pseudocode of Horowitz and Sahni, is FORTRAN based,
in fact they actually used a FORTRAN preprocessor for some courses 
taught out of their books.

As for using C in such a book, well I think this would be tragic. Just
as C programmers like to deprecate Pascal as a teaching toy, the C
language is wide open to charges of unsuitability as a teaching tool.
Let's admit it; C is about as silly as a first computer language can
be if you want to teach anything at a college level. You have to
treat bizarre style issues in C like when to use for or while, and 
how to keep the students from running wild with the side-effect operators
to compact their code onto one line. 

Here at Morgan Stanley, we often hire people who don't program but who
have expertise in science, engineering or finance. We teach them APL
as a first language, because it's what we use. When you have to read
code in a poorly structured language written by people who are not
likely to become concerned with style, correctness, and maintainability
you have to deal with a lot of bugs and hassles I suspect wouldn't
appear in a better structured language. I shudder to think if we
didn't hire a professional staff for our C programming, (which we
do, and they are excellent, BTW) but this has to be seen as a limit
on the accessibility and readability of C, similar to that (if not even
worse than that of APL).

Later,
Andrew Mullhaupt
Disclaimer: Any opinions expressed above are not necessarily those of
Morgan Stanley and Co., Inc.



More information about the Comp.lang.c mailing list