Newsgroups: comp.lang.lisp,sci.logic,comp.ai,sci.math
Path: cantaloupe.srv.cs.cmu.edu!nntp.club.cc.cmu.edu!miner.usbm.gov!news.er.usgs.gov!news1.radix.net!news.cais.net!news.mathworks.com!news-peer.gsl.net!news.gsl.net!ix.netcom.com!netcom.com!vrotney
From: vrotney@netcom.com (William Paul Vrotney)
Subject: Re: Lisp compilers/books (long)
In-Reply-To: John David Stone's message of 04 Sep 1996 14:44:31 -0500
Message-ID: <vrotneyDx96wL.E78@netcom.com>
Organization: NETCOM On-line Communication Services (408 261-4700 guest)
References: <50hbpv$suq@franklin.math.grin.edu> <50j0t1$lk5@nw101.infi.net> <udg24ynjz4.fsf_-_@post.math.grin.edu>
Distribution: inet
Date: Thu, 5 Sep 1996 09:41:09 GMT
Lines: 62
Sender: vrotney@netcom20.netcom.com
Xref: glinda.oz.cs.cmu.edu comp.lang.lisp:22541 sci.logic:20045 comp.ai:40779 sci.math:159721

In article <udg24ynjz4.fsf_-_@post.math.grin.edu> John David Stone <stone@math.grin.edu> writes:

Basically I agree with most of what you say about C++, but I wanted to
augment with a few notes about STL.

>           c) It is not yet standardized.  As a result, most programs in C++
>   are not portable.  They've been working on the preparation of the standard
>   for years, and it's supposedly nearly done now.  The last version of the
>   draft standard that I know of can be found at
>   http://www.csci.csusb.edu/dick/c++std/september/index.html.  But the draft
>   standard has been repeatedly revised, in ways that are not compatible
>   either with existing C++ implementations or with one another, at regular
>   intervals since its first appearance.  The version cited above includes a
>   fairly well-designed container and algorithm library, known as the Standard
>   Template Library, that is in my opinion the best feature of the language.

If STL is the best feature of the language then C++ is in trouble.  Although
the design of STL and the concept of Iterators is clever, the Iterators
paradigm does not seem to fit lists very well.  It better fits containers
like Vectors and Deques.  Most containers supplied, including the last two I
cited are represented as arrays.  If you want to use lists you have to use
doubly linked lists whether you like it or not.  Clearly, insertion into
doubly linked lists is less efficient than singly linked lists.  This was
done, as far as I can tell, to accommodate the generality of Reverse
Iterators.  So here we have the C++ experts, who profess program efficiency
extremism, accepting less efficiency for the sake of generality.

Furthermore lists are treated only as simple sequences.  There is no concept
of a Cons as in Lisp where not only sequence lists but trees can be built.
I guess if you want to build trees you are expected to define special tree
nodes for every type you want to hang in a tree.  Either that or you are
expected to purchase some vendors tree library.  You can not have
heterogeneous containers.  I suppose the C++ experts have a problem here
with these kind of data structures, and so avoid them, because this
difficulty is an inevitable result of static typing.  They help, but things
like virtual functions and RTTI are clever tricks in the small, they don't
cut it for the big picture.

Finally, templates themselves are another clever invention.  But for all
their time efficiency achievements they introduce a space efficiency problem
called "code bloat".  Although syntactically templates seem rather harmless,
for a complex system with a lot of types the myriad of permutations of
common methods on those types results in a huge amount of code generation.
And for existing computers, space and time are still related.  STL attacks
code bloat by having a clever static way to pass function objects but it
doesn't eliminate it.

The bottom line, IMHO, is that if you want to write the same kind of
programs that you typically write in Lisp, STL does not go out of its way to
be helpful here.

>   But no textbook yet published deals with it, because it was added to the
>   draft standard only about a year ago, replacing a whole series of libraries
>   that used a completely different interface.

There is a textbook called "The STL Tutorial", authors Musser & Saini.



-- 

William P. Vrotney - vrotney@netcom.com
