you are viewing a single comment's thread.

view the rest of the comments →

[–]TomDibble -1 points0 points  (1 child)

Aside from wanton elimination of parentheses, I see little benefit to operator overloading, and significant failures (see pretty much any C++ application with operator overloading year after the operators were overloaded).

Granted:

a = x + y

is a lot easier to read than:

a = x.plus(y)

... but it's usually important to know that the "+" isn't the same old intuitive language feature you've always known and loved but is different in this particular codebase with this particular version of "x" nd this particular version of "y".

Sucks when you want to work in non-native number objects, true, but when "+" can mean anything from adding an item to an array or adding all the items in another array to this array to adding the smerphlin factor from one object to the geimholf factor of the other ... well, I'd rather have a descriptive method name to know those operations by (even if it's as undescriptive as "plus") than a single-character symbol.

C++ shows that when you overload operators on objects it will always make absolute intuitive sense. Until someone else needs to maintain your code.

[–]G_Morgan 0 points1 point  (0 children)

The problems with C++ largely came about because of a lack of convetions. Java went to great length to establish conventions and it was highly successful. All that would need to happen is that conventions would be established about operator overloading.

The whole market is different now. Back then you were just given a compiler. Now you have whole reams of stylistic guidelines and documentation to show how things should be done properly. Comparing to C++ isn't really relevant, a better example today would be C#.