To view parent comment, click here.
To read all comments associated with this story, please click here.
The problem with operator overloading is that it doesn't immediately make it clear to the programmer what's happening when you see a line of code. I used to be in the C++ camp, firmly believing that the lack of operator overloading in Java was a bad thing. After having to spend months looking at someone else's C++ code, I'm singing a different tune.
On the other hand, classes like BigDecimal and BigInteger should be treated like String. String has the overloaded + operator, and since BigDecimal and BigInteger are part of the official Java platform, I feel that Sun should have implemented operator overloading for these classes. Operator overloading usually only makes sense when you're writing classes that deal with numeric values of some sort, like a vector or a matrix. Seeing as Java provides all sorts of stuff like XML processing, *two* GUI toolkits, implementing classes like matrices and vectors shouldn't be too much to ask for.
The problem with operator overloading is that it doesn't immediately make it clear to the programmer what's happening when you see a line of code. I used to be in the C++ camp, firmly believing that the lack of operator overloading in Java was a bad thing. After having to spend months looking at someone else's C++ code, I'm singing a different tune.
On the other hand, classes like BigDecimal and BigInteger should be treated like String. String has the overloaded + operator, and since BigDecimal and BigInteger are part of the official Java platform, I feel that Sun should have implemented operator overloading for these classes.
Then you get into more weird special cases like String. In .NET operator overloading is not CLS compliant, so the CLS compliant libraries have to have an alternative non-operator overloaded method. So you have the choice to use or not use operator overloading. I'd rather have a team decision on whether to use them, then let Sun be the decision maker.




Member since:
2006-07-28
Operator overloading hides in single characters in your code, and you have to dig around for it.
You won't have to dig around anymore than any other function with a smart editor. But "digging around" is a symptom of Java-style OO and inheritance in general. Overloaded operators are just like any other function (at least in most languages).
Here http://relo.csail.mit.edu/documentation/relo-vlhcc06.pdf is an interesting paper on the rational for a eclipse plugin called Relo that aids in that "digging around" of large class trees.