Python's "only one way to do it" philosophy isn't good?

Steven D'Aprano steven at REMOVE.THIS.cybersource.com.au
Wed Jun 20 06:29:59 EDT 2007


On Tue, 19 Jun 2007 19:22:33 -0700, Paul Rubin wrote:

> Steven D'Aprano <steve at REMOVE.THIS.cybersource.com.au> writes:
>> So, once you've succeeded in your campaign to make Python more like
>> Scheme, what language will you use for getting real work done?
>> 
>> And how long will it take before Schemers start agitating for it to
>> become more like Scheme?
> 
> While you've dutifully searched the horizon for such intrusion, the rot
> has been quietly happening from within ;-).  Nested scopes, first-class
> functions and closures, internal lambdas, and lazy evaluation streams
> (iterators) are all Schemish incursions into Python.  List
> comprehensions and genexps come from even further in the
> functional-programming "beyond".  Soon Python will implement a type
> system based on the Lambda Cube, well maybe not. :)


All of which makes Douglas Alan's accusations of Not Invented Here 
syndrome about Python seem rather silly. If there was ever a language 
that cherry-picked the best features of other languages, it was Python. 
If macros have been left out, it isn't because Guido has an irrational 
attitude of NIH.

The point I was making isn't that Scheme/Lisp features are "bad", but 
that there is no reason to slavishly follow Scheme just because it is(?) 
technically the most "pure" programming language.

Well, obscurity might be a little harsh. Perhaps a lot harsh. I think so 
long as there are programmers who want to play with programming, there 
will be a place for Scheme, and that place will continue to be sneered at 
by the sort of people who just want the job done, never mind whether it 
is the purest, most lambda-calculus-esque way of doing it or not.

I'm glad somebody understands lambda calculus and closures and meta-
classes, and that those people have created Python so I don't have to. 
And I suspect that for every Douglas Alan enamored with Scheme, there are 
ten thousand programmers who just want to use a handful of pre-built 
tools to get the work done, never mind using macros to create the tools 
they need before they can even start.

It sounds all fine and dandy to talk about creating your own control 
structures with macros. Been there, done that: when I was programming in 
Forth, I was so excited about the ability to define my own control 
structures. Great! Why be limited to boring old IF and WHILE and all the 
others, when I can create my own?

But that quickly passed, because, let's be honest, there really aren't 
that many useful control structures. There is a reason that most 
languages offer the same old boring IFs and WHILEs and FORs, instead of 
exciting new ones. 

As a Python programmer, maybe I'd like to see a CASE statement, but I 
don't _really_ need it. That's just an optimization. Same for REPEAT 
UNTIL: it would be a nice to have, not a must have.

Same for macros -- if there is a sufficiently compelling use case for 
macros, one which won't end up with Python code turning into a billion 
different mini-languages, then I have trust that the Python-dev folk will 
eventually add it into the language. But "Scheme has macros" isn't a 
justification for why Python should have them.



-- 
Steven.



More information about the Python-list mailing list