A rant about Python
I love the Python programming language. I really love it. But there are some things that I hate about it.
Things that I really really love about Python:
- Semantic indentation! It is the greatest idea ever.
- The “There’s only one way to do it” philosophy.
- Batteries included.
- Minimal syntactic fuss (as opposed to perl).
- String interpolation using the cute “%” operator.
- The exhilarating feeling when writing Python (as described in xkcd 353).
Things that I strongly dislike:
- Why no tabs? Space characters should not be allowed at the beginning of a line. They are inherently ambiguous.
- Weird names with two underscores.
- Sigils (@) and unnecessary punctuation (:)
- The string concatenation operator “+” is misleading (concatenation is not commutative!). Any other character would be much better than the plus sign. For example, a space, a dot, two dots, three dots, a comma, or even the minus sign (which does not look commutative). It is tragic that the language was designed by a mathematician!
- The unnecessary existence of mutable and immutable data at the same time. This goes against the underlying principle of simplicity.
- Single quotes, double quotes and sixtuple quotes (wtf!)
- Launching the python interpreter is extermely slow. I want to run the interpreter a few times inside a shell loop to perform a simple computation. However, this is not practical, because launching the python interpreter is excruciatingly slow, but there is no reason it should not be (other that it was not intended to be used that way). The best tools are those that can be used in unintended ways, but sadly Python lacks in this respect.
- Why Tuples and Lists? Really, WHY?
- Why Tuples, Lists AND Dictionaries? Aren’t dictionaries already enough for all purposes?
- Poor UNIX intergration: It is extremely difficult and inconvenient to call external programs, give them some standard input, and capture their standard output.
- Unnecessary exceptions sillyness.
- Unnecessary object orientation sillyness.
- The source code of the interpreter is a huge, complicated, unholy mess. I want the interpreter in a single compilable file “python.c” than I can send alongisde my script so that anybody with a C compiler can run it.
And for those doing “science”:
- Numpy is an abomination. To the already crazy choice of Tuples, Lists and Dictionaries, it adds Arrays and Matrices. It sounds like a sick joke in obfuscation. Now, I have five incompatible ways to store a matrix, and twenty ways to convert between them. There’s more than one way to do it! (Note: the usual response to this complaint is that “you should not use this feature”. But this avoids the question of why the feature exists to begin with.)
- Matplotlib is slow to the point of unusability. Moreover, the plots are ugly. I like ugly plots, but they must be fast, at least.
- PIL cannot deal with any image format that I need (for example, floating point tiffs with an arbitrary number of channels)
I would not care about the ugly things if I did not like the language so much. They make me confused and sad. The feeling is like witnessing a child paint the Gioconda right in front of you, and when you are about to congratulate him, he starts adding glitter and pink ponies in the background.