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

Steven D'Aprano steve at REMOVE.THIS.cybersource.com.au
Sat Jun 23 01:23:07 EDT 2007


On Fri, 22 Jun 2007 19:51:28 -0400, Douglas Alan wrote:

> You seem oblivious to the fact that one of the huge benefits of Python
> is its elegant and readable syntax.  The problem with not having a
> "flexible syntax", is that a programming language can't provide
> off-the-shelf an elegant syntax for all functionality that will ever
> be needed.

It is hardly "off-the-shelf" if somebody has to create new syntax for it.



> Eventually programmers find themselves in need of new
> elegant functionality, but without a corresponding elegant syntax to
> go along with the new functionality, the result is code that does not
> look elegant and is therefore difficult to read and thus maintain.

That's true, as far as it goes, but I think you over-state your
case. The syntax included in Python is excellent for most things, and even
at its weakest, is still good. I can't think of any part of Python's
syntax that is out-and-out bad.

The reality is, one can go a long, long, long distance with Python's
syntax. Most requests for "new syntax" I've seen fall into a few
categories:

* optimization, e.g. case, repeat, multi-line lambda
* "language Foo looks like this, it is kewl"
* the usual braces/whitespace flamewars
* trying to get static type checking into the language


So let's be specific -- what do you think Python's syntax is missing? If
Python did have a macro facility, what would you change?

It is easy to point to functional features Python is missing, but are they
functions that can't be elegantly written without new syntax? Given
that not everybody is convinced that Python needs static type checking,
the only obvious hole I can see is the lack of syntax for
repeat-at-least-once.


[snip]

> Take the issue up with Paul Graham.  Since making a fortune developing
> software in Lisp (making heavy use of macros), he now has much more
> free time to write essays defending the truth than I do:
> 
>    http://www.paulgraham.com/avg.html


I think the #1 advantage to using Lisp in a commercial enterprise is only
indirectly related to the language. Lisp coders are a self-selecting
above-average bunch -- no VB drones or C code monkeys need apply.

Graham talks about 25% of the Viaweb code base being macros. Imagine how
productive his coders would have been if the language was not quite
so minimalistic, so that they could do what they wanted without the
_lack_ of syntax getting in the way.



-- 
Steven.




More information about the Python-list mailing list