Operator overloading has been traditionally overused, especially in C++ (shift operators for iostreams, C++ iterators).
Java was the peak of the push-back against that. C# has operator overloading, but forbids many things that were possible in C++:
* `operator=` and `operator ,`
* `operator new` and `operator delete`
* `operator +=` overloaded differently from `operator +`
* `operator &&` and `operator ||` overloading works differently in C#, so that it preserves the short-circuiting behavior
* `operator ++` only can be overloaded once in C#, with the compiler automatically handling the difference between pre- and post-increment
But more crucially, the C# standard library uses operator overloading only for types like `decimal` and `BigInteger`. C# programmers can go years without ever overloading an operator, while still profiting from it whenever they use `BigInteger`.
It's very different from the C++ culture where
* everyone needs to learn about how to overload `operator=` (for memory management)
* the standard library encourage abuses of operator overloading such as shift operators for iostreams
It should be unsurprising novice programmers abuse operator overloading when the C++ language teaches them exactly that.
Except C++ didn't learn that operator overloading is bad. C++ learned that operator overloading for everything was bad.
The language kind of put itself into a corner when what C# calls `MoveNext` is called `++` (with two variants of course) and what C# calls `Current` is called `*`. Taking what mathematically worked for iterating an array and taking it piecemeal to define your syntax is the kind of operator overloading that is a bad idea.
People don't appreciate how much of an impact C++ had on C#. People consider it a Java clone, but the first version had many features to support a large segment of C++ (COM) developers that Microsoft wanted to move to .NET. This brought a visible performance hubbub at the time which was often instigated by the folks more comfortable with C++, manual memory management, etc.
You are missing the part where Java's clone done by Microsoft, J++ already had those features, and it was the first project Anders worked at Microsoft, hence it also has the property/event ideas from Delphi, and a framework that was the predecessor of Windows Forms.
These were the major pain points for the Java lawsuit that Sun did against Microsoft.
The irony with all these attempts to make COM easier to use is that they always fail flat when the Windows dev team has their turn, and then they undo everything and we are back into C++ and IDL land (latest version of it, C++/WinRT).
Python has operator overloading now. (And as far as I know, always has.) Avoiding operator overloading was one of several weird, idiosyncratic decisions Java made.
Operator overloading in a language in which memory management is all manual would be more challenging. That doesn't really tell us about its suitability in a language with automatic memory management. We've had about 20 years of C# with operator overloading, and it's been totally fine.
We who? From where I stand people are fine with operator overloading where it makes sense and C++ is far from being the only language with this feature.
Problem comes when shitty programmers get orgasmic about some language feature and try to use it everywhere to everyone's detriment.
You have to have real good taste to use operator overloading. Often it just leads to obfuscated code where the operators have weird behavior. Extension methods are also way overused. I have had numerous occasions where I thought the .NET framework was buggy only find out that it was somebody’s badly written extension method causing problems.
Gross exaggeration. Just a bit of plain common sense. Do override operators to perform matrix ops. Do not override + operator to do multiplication instead. And do not subtract apples from cars.
As for your further example as I said give shitty programmer code in any language and they will manage to fuck it up.
I think you and the parent are saying basically the same thing. I've been working in Scala for the past 10ish years and we have definitely gone through the "hype cycle" of operator overloading. Early Scala libs went a little nuts with creating an incredible array of symbolic operators (most famously this atrocity http://www.flotsam.nl/dispatch-periodic-table.html). We collectively realized that this was overboard and now Scala libraries typically provide a more modest set of symbolic operators (and generally the symbolic operators are just aliases for named methods so you can decide which ones you want to use in any particular codebase).
I would also disagree with the characterization as shitty code. The operators are actually really nice if you manage to learn them all well. It can make the code both very concise and readable. But it optimized for people who know the libraries extremely well over people who don't, which usually is not a great tradeoff for widely used libraries.
>"The operators are actually really nice if you manage to learn them all well. It can make the code both very concise and readable."
This sounds suspiciously regex like. Concise it is, readable it is not. But regex is unique case and and harassing people with similar patterns in every line of code should be punishable by at least 10 years of maintaining complex software written in Brainfuck.
I only know two or three game devs but they all use C++ spitefully because there isn’t any better options to them at the moment. They’re all itching for something better and there are lots of options that are becoming viable so maybe C++ won’t be the only game in town.