Operator Overloading is Evil

Especially in Python

Rob Muhlestein
Aug 31, 2018 · 3 min read

Recently the students and I have been anticipating the modern JavaScript pipe operator (|>) (which it stole from Elixir or Julia).

Python doesn’t have it (like so many other things).

Python has something far worse: operator overloading.

One student found this ‘Hacker Noon’ post suggesting to use overloading to create an actual pipe | operator.

The more I got to thinking about it—having been forced to use overloading for a lot for modern Python paths that use overloading to make the slash / into a path join method—the more it bothered me how blatantly opposed to Python’s stated direction of simplicity and abhorrence for context-specific constructs, you know, the stuff that Perl programmers loved and people hated Perl for who also liked Python, the very reason Python is said to have “won” against Perl, the whole simplicity and explicitness.

Operator overloading is the antithesis of simplicity, expectation, and predictable context.

Python turns out to be a hypocrite once again (much like many of the conservatives who use it).

At this point I am getting serious tired of being reminded just how bad Python is having taught it so sincerely for five years because I felt it was the “right thing to do” even though I could never find an actual use for it both at work or personally other than to “teach to beginners because it is simple.”

You wanna know what is not simple? Operator overloading. It has no place in any language. It’s an aberration to be shunned.

Out of curiosity I read up on why Go has very specifically decided to leave it out, low and behold, the explanation is (once again) spot on.

Method dispatch is simplified if it doesn’t need to do type matching as well. Experience with other languages told us that having a variety of methods with the same name but different signatures was occasionally useful but that it could also be confusing and fragile in practice. Matching only by name and requiring consistency in the types was a major simplifying decision in Go’s type system.

Regarding operator overloading, it seems more a convenience than an absolute requirement. Again, things are simpler without it.

“Things are simpler without it.”

So why would the language touted as the simplest for beginners and advanced users alike, with a disdain for context-specific constructs include them?

You can guess at the answer but I’ll go right out and say it.

Python was designed by lesser computer scientists ages ago and carries an enormous amount of baggage and now bloat. As amazing as Guido’s contribution to the world has been, you have to wonder if he stepped down seeing everything around him, seeing the emergence of modern, cross-compiled languages and bury Python on every count.

This tiny blog won’t change the fact that millions of people think Python is the best language ever created, but there is overwhelming evidence to the contrary for anyone really paying attention, no matter how hard that cognitive dissonance is to swallow.

I write a post like this both to get the frustration out of my system as well as proclaim a warning to all those who would be willing to examine the objective conclusions with me themselves.

Rob Muhlestein

Written by

/^((Found|Teach|Hack)er|(Men|Jani)tor|C\w+O)$/ 🌎 skilstak.io 💥 robs.io

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade