I'm amazed (and horrified) how come such an intelligent mathematician and designer of a beautiful programming language made such an obvious fuckup of using a commutative operator for string concatenation. Really, I hate python just for this single idiotic notation.
I mean, it's right there in front of your eyes. He talks about the convenience of using a visually commutative operator like "+" for commutative operations, and then a few lines later he says that it is a convenient notation for string concatenation. What. The. Fuck.
I understand the confusion it may cause to a new Python developer who comes from the mathematical background.
Does it cause any problems beyond that? For example, does it interfere with some elegant patterns, or result in some bug prone code, etc?
FWIW, the single main annoyance I've had with python was its treatment of strings as iterables of single character strings. While not wrong in any obvious theoretical sense, it conflicts with the mental model of many developers (both new and experienced) and has probably caused more bugs than any other feature of Python (and even more ugly type checks to avoid such bugs). When people realized it was a problem and discussed removing this feature, Guido said he had tried but (a) it was too much work and (b) he felt the benefits are too great to give up (https://mail.python.org/pipermail/python-3000/2006-April/000...).
> I understand the confusion it may cause to a new Python developer who comes from the mathematical background.
I'm confused mainly because a person with a mathematical background created a language with such an obvious blunder. When I have to use the language (and I do often) I am not confused about string concatenation, I am ashamed of having to use this ridiculous notation.
While it makes sense to think of them as sequences, this has bitten me more than I care to admit.
OT: Is there a name for things we love to complain about, but wouldn't change?
Hmm it does look like the other comment responding to you is correct: + is not always commutative in math: http://mathworld.wolfram.com/OrdinalAddition.html. If mathematicians are fine with that, I'm not sure what argument you may have against this operator being non-commutative in a programming language.
I for one feel that + is a very intuitive choice for concatenating strings and lists. Is there any other common operator you would recommend instead? Because I feel that using a less common one would harm beginner-friendliness significantly.
Also, to the best of my knowledge there is no place in the bible of maths that defines + to be commutative. In particular, addition of (infinite) ordinals is not commutative.
> I for one feel that + is a very intuitive choice for concatenating strings and lists. Is there any other common operator you would recommend instead?
Literally, any other operator would be better than addition. A space, a dot, a product, two dots, a minus sign, whatever. Anything except the visually commutative plus.
> Because I feel that using a less common one would harm beginner-friendliness significantly.
Usage of + for string concatenation is fairly new, probably invented by C++ (which, by the way, uses bit shift operators for output, so it is not really an example of sane language).
> Because I feel that using a less common one would harm beginner-friendliness significantly.
Actually, given that concatenating sequences (strings are an example) is a fairly common operation and for some kinds of sequences, so is adding them elementwise, it would be better not to use a common mathematical operator for concatenation, but to give it its own.
I mean, it's right there in front of your eyes. He talks about the convenience of using a visually commutative operator like "+" for commutative operations, and then a few lines later he says that it is a convenient notation for string concatenation. What. The. Fuck.