[Edu-sig] Lisp vs Scheme vs Python
Kirby Urner
pdx4d@teleport.com
Sat, 26 May 2001 09:11:17 -0700
> Still, in the end if they are confronted with an unusual data class,
> they fail to come up with code. I tested dozens and hundreds of
> students on that. They all had introductions in Pascal or C (min 1
> year) and couldn't write a function that traversed a non-standard
> data class if their life depended on it.
>
> -- Matthias
Are you saying these students usually don't hit on recursive
solutions? If so, I don't wonder. Recursion is usually perceived
as rather exotic and someone who always thinks in terms of for and
while loops may well not come up with the recursive solution when
called upon.
This situation might be addressed by using recursion more often
in Pascal or C (or Python). For example, some of these algorithms
Chris just shared make good use of this strategy (the Tower of
Hanoi is a classic way of introducing this construct).
Probably more than prefix notation, the use of recursion in place
of loops, even for the simplest algorithms, presents the biggest
adjustment in thinking for the would-be Scheme learner -- especially
if coming from another language tradition that doesn't emphasize
it so much (even if the language supports it).
You say Scheme permits a loop concept by means of macros. To
someone who learned Python as a first language, this won't mean
much to them, since Python has no macros -- the very concept will
be undefined.
I agree that some data structures are most adequately dealt with
using recursion (Chris's circuits seem a good example). On the
other hand, I don't see sequential iteration as foreign to
everyday experience either -- it's like a conveyor belt, where
you stand on the side and do the same thing to each object that
goes by, perhaps accumulating some totals.
Or take the sigma notation in mathematics: successive substitution
of an incrementing index, with summation of all the resulting
terms. Such sigmas are the raw material of many an algorithm,
but I have trouble thinking of these as "more naturally" recursive
than simply iterative. Perhaps I need my thinking cap adjusted.
Kirby
PS: thanks for more background on Lisp vs. Scheme. Going back
to some emails from a Lisper trying to educate me on the basics,
I find (> = me, = teacher):
> I think I'm talking about more than just prefix notation,
> although that's part of it. Heavy use of recursion would
> be another part.
But that's a Scheme thing, not a Lisp thing. Lisp has a
large number of iteration constructs, and the use of recursion
to do iteration, as in Scheme, is rather frowned upon.
In fact, since Lisp doesn't guarantee to do tail-recursion
elimination, writing Scheme in Lisp can easily lead to stack
overflows. [Most Lisp implementations *do* do tail call
elimination, but only at non-default optimization settings,
where debuggability isn't considered important...disappearing
stack frames makes debugging a pain]
This guy didn't like Scheme though:
Scheme? Oh, yeah, that nasty little Algol dialect that
tries to look like Lisp. I abhor Scheme.
Here's what I thinks of Python (vs. LISP):
For me, Python's functionality is a proper subset of Lisp's[1],
and Lisp is faster (both in execution time and in coding time)
and easier to use, so I don't have much use for Python; but
its design is simple enough to understand what's going on
without much actual experience (though I completely failed to
understand the document about metaclasses (which I thought
was in the Python src directory, but I can't find it now)
when I read it, despite having _used_ metaclasses in Lisp...)
I doubt that it's possible to know Lisp very well without coming
to understand the huge advantage of S-expression syntax (which,
by the way, you don't have with Scheme -- Scheme source is just
text) and a programmable reader; and having had that, I'd think
it'd be hard to be happy with anything less.
I downloaded a LISP awhile back and played with it some, studied
the CLOS object system. And of course I have DrScheme and very
much admire its easy interface and learner orientation (e.g.
different language levels).