A really bad idea.

djw codeguru at hp.com
Thu Nov 14 12:44:00 EST 2002


M wrote:

> Dear Python Community,
>
> I use Python in several projects. One of the main benefits of doing
> so is that my programmers can quickly learn Python and get productive.
> Python is a great language to read. Very seldom does one of my programmers
> missunderstand code somebody else have written. This is one, if not 
> the most,
> important aspect of a great language. Most of the time are spent in 
> reading
> code while adding a new module (to see where it should fit) or fixing
> bugs. And by definition, for a non-trivial application, this is code that
> somebody else wrote.
>
> The ability to produce readable code is one of the best things with 
> Python.
>
> Python more or less forces you to write nice code. This is a good 
> thing. Not
> an issue when you are a single programmer on a project. But when you 
> have a
> bunch of programmers with different skills this is great.
>
>
> But I see a disturbing trend.
>
> Just a few examples...
> The new enumerate or zip function. If you look at the code using this 
> function
> it is not at all obvious what the code does. Let say a programmer that 
> knows
> 10 other languages looks at this code. I don't think he would right away
> understand what this function does. This construct is not obvious. 
> Generators
> are another thing that are just horrible. They just don't work in a way
> that one would expect from previous experience.
>
> I understand that one will like to add features to a language in order to
> make it more powerfull. But I argue that this must be done in a way so 
> that
> programmers of *different skill levels* will understand the code. C++ 
> is one
> horrible example of a very powerfull language that very few people 
> actually
> understands fully. It takes years to fully understand C++, where does this
> leave time to think about architecture and algorithms?
>
> And no, you can't just say that these constructs should never be used. It
> won't work! Every language feature will eventually be used by somebody.
> Just look at the C++ world. Full of guidelines how to avoid doing things
> that nobody will understand anyway. And full of code that breaks these
> guidelines.
>
> I hope this is not a start of adding powerfull and hard to understand
> features to Python.
>
> Cheers
> /Marv

If Python was the same as all other languages (thus making it easy for a 
programmer to easily understand it), it would be like all other 
languages (that is to say, not very useful). What makes it special is 
that it has powerful constructs that other languages lack. When I first 
looked at Python code, I didn't have a clue that {}'s meant a dictionary 
and that [::] was a slice operator. After learning these, they become 
natural. What I worry about is not things that seem wierd at first, but 
things that continue to feel wierd over time and force me to grab the 
documentation every time I try to use it (example, the dictionary 
setdefault() method. I have to look that sucker up every time. Also, 
"".join() always seems wierd.)  Stuff like generators, list 
comprehensions, etc... languages like C++ don't have these things, why 
would you expect a C++ programmer to get them? As long as _Python_ 
programmers find it natural, why should we care if C++ programmers 
don't? 8^)

Just my $0.02,

/d/




More information about the Python-list mailing list