Thursday, March 21, 2019

Why Operators Are Useful

Guido van Rossum:

The general idea here is that once you’ve learned this simple notation, equations written using them are easier to manipulate than equations written using functional notation -- it is as if our brains grasp the operators using different brain machinery, and this is more efficient.

[…]

Now, programming isn’t exactly the same activity as math, but we all know that Readability Counts, and this is where operator overloading in Python comes in. Once you’ve internalized the simple properties which operators tend to have, using + for string or list concatenation becomes more readable than a pure OO notation, and (2) and (3) above explain (in part) why that is.

Of course, it’s definitely possible to overdo this -- then you get Perl.

Observing the use of custom operators can help identify problem spots in a language.

Comments RSS · Twitter

Leave a Comment