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

Steven D'Aprano steve at REMOVE.THIS.cybersource.com.au
Fri Jun 22 23:42:51 EDT 2007


On Fri, 22 Jun 2007 13:54:35 -0400, Douglas Alan wrote:

>> Python already allows me to shoot myself in the foot, if I wish. I'm 
>> comfortable with that level of freedom. I'm not necessarily comfortable 
>> with extensions to the language that would allow me the freedom to shoot 
>> myself in the head.
> 
> Lisp macros don't let you shoot yourself in the head -- only in the
> foot.  Being able to do
> 
>    True = False
> 
> is being able to shoot yourself in the head.  And Python certainly
> lets you do that.

True, that is a current piece of badness. There are arguments for and
against making True and False reserved words, like None.

Nevertheless, in Python 1+2 always equals 3. You can't say the same thing
about Lisp.

 
>> I would need to be convinced of the advantages, as would many other
>> people, including the BDFL.
> 
> The proof is in the pudding for anyone who has seen the advantages it
> brings to Lisp.  As Paul Graham points out, it's hard to look up and
> see the advantages of what is up there in a more powerful language.
> It's only easy to look down and see the disadvantages of what is missing
> from a less powerful language.  To understand the advantages, one has to
> be willing to climb the hill and take in the view.

I don't accept Graham's reasoning.

I think that it is true that people's *values* change, as they get more
familiar with a more powerful language. For instance, I used to write
Pascal code on a Mac, and I avoided object-oriented techniques because
they were too inefficient and slow. (E.g. when Apple released System
7, which used OO code extensively, even the most one-eyed Mac fan boys
had to admit that the Finder ran like a dog compared to System 6.) But the
advantages were obvious, even before I had experience with OO design.

Now, I use Python, which is all object-oriented -- but the hardware I run
it on is so much faster that I care more about the programmer productivity
(my time) than about the efficiency of the executed code (the computer's
time). But if I were still running on a 1988-vintage Mac, you better believe I
wouldn't be making the same trade-offs I am now.

So, quite frankly, the things which you and Graham value in Lisp *simply
don't interest me*. It isn't that I can't see the advantages. They just
don't matter to me, in fact in some ways they are disadvantages.

Could my opinion ever change? Of course it could. I might, for example,
suddenly have a burning passion about language design, or find some
problem that is really painful under Python, and then I might go searching
for "a more powerful language". One doesn't need to be familiar with more
powerful languages to be aware that they offer benefits that less powerful
languages don't.

Or some really smart people might come up with a macro system that reduces
the disadvantages while keeping the advantages, and then dealing with
some random module developer's syntax extensions no more frightening than
dealing with some random module developer's functions.

(Considering the poor design and shoddy code of some modules I've had to
deal with, I really worry about giving developers the ability to redefine
syntax too.)

[snip]


>> let alone whether the benefits would outweigh the costs,
> 
> They pay off in boatloads in the Lisp community.

But do they? Where is the standard library containing all these
magnificent macros? Forcing people to implement basic things from scratch
doesn't sound like a pay-off to me.

It seems that one of the major costs of having an extremely minimalist,
but easily extensible, syntax is that it encourages massive re-invention
of the wheel. Things get moved into the language slowly, because it is so
easy to work around the lack -- but the cost is a proliferation of
different macros all doing the same thing.

I think Python has the better philosophy. Python has one really good
syntax, minimalistic but not _overly_ minimalistic, not an easily
extensible syntax. The cost is that there are some things which could be
easier, if the syntax were different, but the benefit is that I don't have
to write syntax-extending macros, or debug them, or learn somebody else's.
Once every few years, Python introduces a new syntax, e.g. list
comprehensions, after much thought. That's better than every time I use a
different library or module.


-- 
Steven.




More information about the Python-list mailing list