Scheme style and Python style [was: Re: Typed Python?]

Michele Simionato michele.simionato at gmail.com
Wed Jul 7 12:38:18 EDT 2004


François Pinard <pinard at iro.umontreal.ca> wrote in message news:<mailman.420.1089031230.27577.python-list at python.org>...
> But as someone who much liked both Scheme and Python, let me stress a
> few aspects where Python attracted me more than Scheme.
> 
> The most important one is the bulk of library code which comes standard
> with Python, but which has to be collected or rewritten in Scheme, not
> being part of the standard.
> 
> Another is that, despite Scheme attempts to be minimalist (something
> that I much like), Python is -- or at least once was! :-) -- more on the
> side of having only one way of doing things.  Two examples come to mind.
> 
> Scheme has three ways to write a conditional statement: `(cond ...)',
> `(if ...)' and `(case ...)'. All have virtues and drawbacks, and I often
> switch between the three, depending on my code, and the edits I do on my
> code, so it stays best at all time.  This is annoying.
> 
> Scheme has many ways for looping while changing local variables, some
> of which are less nice and which I did not use much, I'm not even
> discussing them.  The `(let loop ...)' construct is useful for writing
> tail-recursive loops without creating a flurry of little separate
> functions, but it is often clearer writing destructive `(set! ...)'
> instead of always being tail-recursive, even if tail-recursivity
> often yields more efficient compilation.  When you mix assignment and
> tail-recursion, the amount of solutions for a piece a code is near
> exponential in the number of variables.  I found this annoying, too.
> 
> Bindings, conditionals and loops are very basic and ubiquitous in any
> programming language, and Python got these relatively simpler than
> Scheme.  Scheme may be minimalist overall, but because of the frequency
> of the above constructs in a program, the minimalism is not so apparent.

Interesting that you make these remarks. One of my major complaints
about
Scheme (about aestetical aspects) was just that fact which is
advertised
as a minimalistic language but is not: the cruft you notice, an
useless/redundant "do" construct, too many let, let*, letrec, define,
inner
defines, etc. It is minimalistic only when it comes to the lack of
useful
standard libraries :-(

OTOH, things that Scheme has better than Python are the scope rules,
the
recursive structures and some functional stuff (but this is kind of
obvious).

> P.S. - On the other side, in those rare circumstances one needs
> continuations, Scheme offers them very easily, while there are rather
> painful to simulate in standard Python.  Also, there once was a notable
> distance between Scheme and Python about lazy evaluation and closure
> construction, but more recent versions of Python offer fairly tractable,
> almost easy approaches for such things.

Yes, indeed having iterators and generators built-in in the language
(as well as an exception system) exaust most of the use case for
continuation so you don't really feel the need for them in Python in
normal circumstances.


                     Michele Simionato



More information about the Python-list mailing list