[prog] Sample implementations of UNIX utilities.

Robert J. Hansen cortana at earthlink.net
Wed Dec 25 14:40:21 EST 2002


> enjoyed Miranda in the same course in which I learned LISP.  It isn't
> *functional programming* that I found irritating about LISP, it was,
> indeed, the irritating stupid parentheses, which contributed to its
> sheer unreadableness.  Not to mention the cryptic commands like 'cdr'.

I imagine that, much like C's seemingly-obscure naming conventions ("what do
you _mean_, this function has a prototype of `void weirdsort(void* begin,
void* end, int size, CMPR_FUN_PTR)'?") get easier the more you deal with
them, LISP gets easier the more you deal with it.  When I was an undergrad I
would have heartily agreed with you that the endless parens were nothing but
trouble.  Nowadays, though, they don't bother me that much.

> Prolog was much cleaner.

Mmmm.  Prolog.  :)

> Mind you, I've gotten the impression that if one wants to actually *do*
> anything in a functional language, the pure beauty and elegance of the
> interface tends to get kruft tacked on in order to interact with the
> messy outside world.

Depends on what you want to do.  For pure computational tasks, it can't be
beat.  Once you have to interact with the outside world... yeah.  Cruft.

OTOH, breaking things up into interface-backend helps considerably.
Isolates the crufty bits and lets the back-end remain elegant.

> Or Lambda Calculus?

Lambda's cool.  :)

> I was thinking more in terms of the sheer number of platforms that
> actually have C/C++ compilers either as standard or easily available.
> Or are you going to tell me that there's a LISP compiler that comes on
> the Solaris supplemental install disk, for example?

Free (as in beer) implementations of SML, Ocaml, LISP and Scheme are readily
available for Solaris--I found all of them in under two minutes of Googling.

Scheme may come on the Solaris install disks, BTW.  One of the Solaris disks
has a lot of GNU utils, and it wouldn't surprise me to find Guile (GNU
Scheme) on it.

> Now, maybe if you're only sticking to Linux systems where you can easily
> install everything and the kitchen sink, you can afford to range further
> afield, but if you have something which needs to work across Solaris,
> HP, Dec, IBM and Linux, say, on systems which are controlled by someone
> else (the client) who won't give you root access and doesn't want you
> installing a whole heap of ancillary programs... C/C++ is the safest bet.

Now we're changing the nature of what's being argued [*]--not that I mind,
of course; digressions are half the fun of any conversation.  :)  Yes, many
languages are seriously hampered by noncomputational problems like what
libraries the client has installed.  Fortunately, LISP isn't one of
them--many implementations compile LISP down to executable code which uses
the C runtime.  Others, such as Scheme, SML, etc., are right out the instant
that "works without additional libraries" is added as a constraint.

[*] I was tempted to use the word `discussed', but... I stuck with `argued'.
But please don't think I'm treating this like an argument.  :)

> All that being said, Java looks promising for doing pretty UI frontends
> which are crossplatform -- while doing the backend in whatever you want
> (such as the already-existing C/C++ backend... (grin))

A couple of months ago while TAing a software design class, I showed the
class the Sieve of Eratosthenes as written in LISP, SML, C++ and Java, along
with how long it took me to write each, and how long it took to compute
primes up to 100,000:

LISP: 20m writing, approx 2m execution
SML: 15m writing, approx 3m execution
C++: 30m writing, < 1sec execution [**]
Java: 20m writing, 4m45s execution [***]

[**] By doing Cool Stuff with templates, I was able to do most of the
computation in the compile step.  Cool beans.  :)

[***] I was able to optimize the Java time down to 55s, but at great cost in
program clarity.

... Obviously, after that experiment I lost all faith in Java as a platform
for serious numerical computation.  :)

> Oh, and Merry Christmas!

Merry Christmas to you, too.  :)




More information about the Programming mailing list