by christian_schli... - 2005-12-15 11:04
by dog - 2005-12-13 12:40
It's called C++. If you want C++ use C++.. otherwise use Java.
by archangel - 2005-12-14 06:24
by dog - 2005-12-14 09:01
Java was designed with a certain philosophy. To violate the language's philosophy only makes it messy. I believe Java's strength was to be a "cleaner C++". To add C++ features (especially this late in the game) only makes it messy.
I believe in the "less is more" philosophy. If you want something else add it to the library. Since Java initially came out with no operator overloading.. we're all used to it anyways, then why add it this late in the game. It's also only useful for a handful of mathematical classes. We'll survive w/o it.
A bigger danger is to have to deal w/ messy ++ iterators and junk like that, that ex-C++ developers will love to add to their libraries and make our code as unreadable as STL.
by archangel - 2005-12-13 01:59
by sjasja - 2005-12-15 03:58
You could misuse a lot of things. But practical experience suggests people don't habitually abuse most features to produce "insane code". Practical experience with C++ also suggests operator overloading is often misused for cutesy tricks.
It isn't about whether operator overloading could be misused, it is that it is misused. That is not a theoretical question, it is a practical one with real life evidence.
by alexlamsl - 2005-12-13 04:05
by jhogan - 2005-12-12 11:26
by grlea - 2005-12-11 15:12
by bbjwerner - 2005-12-09 11:48
by stevedbrown - 2005-12-09 10:41
by leouser - 2005-12-12 12:16
by alexlamsl - 2005-12-09 06:33
Operator Overloading would break more contracts of simplicity, beauty and safety of the Java Language that it is not worth the convenience gained.
I'm curious though, that so far I haven't heard about people proposing alternative means to achieve the same or similar convenience provided by this over-debated language feature.
by archangel - 2005-12-09 05:19
by eirikma - 2005-12-09 08:53
by rickcarson - 2005-12-13 21:35
So 'Vector v3 = v1 + v2' would mean create a new Vector consisting of firstly all the objects in v1 and secondly all the objects in v2.
This might be a problem if v1 and v2 contained different types of objects, (hmmm... generics...). Also it is not clear what the - operation would do.
You could extend that to all the collections. Of course, for the ones that implement the Set interface, the meaning would have to be slightly different. + would be the union of the two sets, - might be the intersection of the two?
NB: yes, I do know that you were actually talking about matrix arithmetic :D
by jlusk4 - 2005-12-09 08:34
by applebanana8 - 2005-12-12 11:55
by sjasja - 2005-12-15 04:26
I beg to differ.
If someone is trying to break the primary tools of my trade, I think I have the right to offer a differing opninion rather than automatically resigning my job.
"I have to maintain code that uses bad features" and "years of practical experience shows this feature is often used for creating bogus APIs" are perfectly valid arguments.
by insac - 2005-12-09 07:53
by ted_jones - 2011-07-06 08:06
The lack of operator overloading in java severly restricts the use of the language in any scientific application. Any significant equation is going to be unreadable using methods. There was at least one good example given above but I have code containing equations far more complicated that would be nearly impossible to implement in a readable fashion in java.
I think that the developers of the language, and many of the respondants on this thread, are under the mistaken impression that it is the responsibility of a programming language to prevent developers from doing something stupid. This is the developers responsibility and should be enforce through peer reviews, not by restricting the capabilities of the language.
I will provide two examples of the necesity of operator overloading. One, the ==, <= and >= operators on any floating point type are completely useless without it. Even the limitations of precision in a floating point processor require that some tolerance be used for these operators but more than that the individual application requires that a configurable tolerance be provided. Any numeric representation of a physical quantity is only as accurate as you can measure it and only the developer knows what that accuracy is. Granted, one could implement a withinTolerance method but the operators are, IMHO more convinient and easier to read.
The second example is a physics library. I have written one in C++ which, unfortunatly, can not be ported to java without great pain. The idea is that you can, for example, divide a distance by a time and produce a velocity. The classes internally maintain units and ensure consistency. There are many complex equations involving these classes that would be completely unreadable if operator overloading were not available.
My opinion is that the language should provide developers with the tools that make thier lives easier and it is the developers responsibility to exersise appropriate restraint in using these tools.
Your use of this web site or any of its content or software indicates your agreement to be bound by these Terms of Participation.
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.