Newsgroups: comp.lang.scheme
Path: cantaloupe.srv.cs.cmu.edu!rochester!cornellcs!newsstand.cit.cornell.edu!portc01.blue.aol.com!news-peer.gsl.net!news.gsl.net!howland.erols.net!netcom.com!vfr750
From: vfr750@netcom.com (Will Hartung)
Subject: Scheme Style and substance
Message-ID: <vfr750DyxxLC.5z@netcom.com>
Organization: NETCOM On-line Communication Services (408 261-4700 guest)
Date: Tue, 8 Oct 1996 04:53:36 GMT
Lines: 92
Sender: vfr750@netcom11.netcom.com

The recent threads over style and elegance are particulary pertinent
to me today, being as I FINALLY sat down and managed to pound out a
few hundred lines in the blankity-blank language last weekend.

I've been book reading a lot, and doing little exercises, but I
haven't done anything that was my own until now.

So.

After all was said and done, and with all that was posted, I went back
over my code for a little fashion audit.

I found some interesting trends. Some of my earliest stuff had set!
scattered hither and yon throughout it. In retropspect, this code
looks TERRIBLE. Later on I rely on a plethora of let's, let*'s and
letrec. Save for one function, I use set! extremely sparingly.

I find I do a lot of:
    (let* ((a 1)
           (b (+ a 1))
           (c (+ b 1)))
     c)

Whenever I need a new variable, a "let" magically appears.

I think that if a lambda expression gets a little too big, that it
should be pulled out into a helper function, and then used. I've got a
'map' statement with a 15 line lambda definition that seems difficult
to follow. By the time you reach the end of the lamda function, you
forget you're actually buried in a 'map'.

I find 'do' loops remarkably ugly. I appreciate how, is some cases, do
loops may never actually have a 'body', but when they get large, they
get ugly and hard to follow. I think I'm more inclined to use
tail-recursion even for simple iterations.

I used recursion a zillion more times in this little program than I
have in my entire life. Yet, the program still smiles at me when I
read it. This is good.

Overall, I was really pleased with the whole experience. I know that
if I had started this program out in C, I'd have never finished it.
The utility of the program is nice, now that it is complete, but the
real purpose was to get me neck deep into a Scheme situation.

I'm confidant that C would have just continually gotten in the way of
what I was trying to do, whereas Scheme just played along. I use lists
heavily, as is natural. Nothing is natural in C.

I could have pounded it out in QBASIC or Visual Basic, but it still
would have been frustrating I think. Bulky. Painting with a brick
instead of a brush.

It was exciting. For me. I like the (almost) complete lack of user
interface for what I'm doing, relying on the eval-print loop. It even
made me appreciate EMACS (which I've avoided for years) because of the
decent integration between the Scheme mode and the inferior Scheme
process.

Is my program efficient? Hmmm..I don't know. I'm probably cons-ing too
much. Throwing a lot of stuff away. SCM says it takes, roughly, 10
mSec and 5000 cells of work. If I run it 1000 times, it takes 12 secs
with 30% in GC and uses 5000000 cells.

I have no idea how long a comparable C or BASIC program would take. I'm
not really inclined to write one and check, either. But then, I don't
run this program by the thousands, either. So, how important is it
really?

Is there a lot of style over substance? Is there a price for my little
babbling brook of a program over a steel viaduct forged in C that will
probably only sit and rust in the future instead of flowering and
bringing new life? Perhaps. 

Is that the Scheme Way? Well Yes, I say. And No, from what I hear.

Scheme is clearly VERY idiomatic. That's the nature of expressive
languages. It helps to know the chords of the language as well as the
notes. This program is pretty much your grunge band garage audition,
with few chords, few time changes, and a simple beat. But, now that I've
written some of my own music, I can more easily read others.

And learn some more chords. 

So I can make better music...

Or, perhaps, even better metaphors :-)!!

-- 
Will Hartung - Rancho Santa Margarita. It's a dry heat. vfr750@netcom.com
1990 VFR750 - VFR=Very Red    "Ho, HaHa, Dodge, Parry, Spin, HA! THRUST!"
1993 Explorer - Cage? Hell, it's a prison.                    -D. Duck
