… the more I like about Perl
The Company I am working for uses Python. As a programmer with over 20 years of experience in several languages, I can read Python without much difficulty. And, because I’m employed to do internal documentation, not develop code, it doesn’t really matter that I’m not a Python programmer. Still, I figured it behooves me to learn a little bit about Python.
An internal introductory class is being offered so I’m attending.
I’m not impressed.
Even before this job, I didn’t have much to say for the “indentation is magical” argument. Nor did I much agree with “There’s Only One Way to Do It”. Spouse doesn’t care for the fact that, in Python, pretty much everything requires using a module (and I have to agree with that).
Recently, however, I’ve run across a couple of really ugly “features” of Python.
For one, I wasn’t particularly impressed by the rationale that was used to get the += operator into the language.
Apparently Guido van Rossum didn’t want to include that operator and, given the theory of Python as a language designed to be simple, I tend to agree. Apparently Guido was convinced because x+=1 is more performance efficient than x = x + 1. Um… if that’s true, that’s just plain wrong.
The one that really got me though, was this little gem we learned last week in the aforementioned Introduction class.
| Example 1 | Example 2 |
|---|---|
|
|
The results are as follows:
| Example 1 | Example 2 |
|---|---|
x: 2
| x: [4, 2, 3]
|
Let’s comment the two programs above with English descriptions.
| Example 1 | Comment | Example 2 |
|---|---|---|
|
|
|
x: 2
| Are x and y still the same?
| x: [4, 2, 3]
|
The class instructor “explained” the reason behind the results.
Two friends, both long-time programmers, explained “how” the results might come out this way.
I Don’t Care.
No explanation can cover up the fact that this didn’t have to happen.
The Python designer had control over the internal workings of the language. It didn’t have to work this way.
Python adherents tout Python’s “clear” language, “elegant syntax”, and “readable programs”. They say that “Python tries to keep things simple, to be orthogonal but not too much so, and to assist the programmer as much as possible.”
Python revels in its simplicity, but the results above violate the KISS principle as well as the Principle of Least Astonishment.
To me, that leads to difficulty explaining the language to new programmers, problems understanding how your program will work… and bugs just waiting to happen.
Leave a comment