Why Java Doesn't Need Operator Overloading (and Very Few Languages Do, Really)
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Sat Apr 18 18:15:05 PDT 2009
Edward Diener wrote:
> Paul D. Anderson wrote:
>> Sounds like someone needs a strong dose of D!!
>>
>> http://java.dzone.com/articles/why-java-doesnt-need-operator
>>
>> The comments bounce between "operator overloading is always bad
>> because you can do idiotic things with it" and "operator overloading
>> is essential because sometimes you really need it".
>>
>> How about a language where operator overloading is available for the
>> cases where you do really need it, but isn't available in general?
>>
>> Hmmm...
>
> Java's lack of operator overloading is the most idiotic language
> decision which I have ever encountered. The arguments against operator
> overloading are equivalent to "if we allow feature X, programmers might
> not use it the way we have decided it should be used, therefore we won't
> allow it". "Idiotic" is not even a strong enough word to describe the
> retrograde thinking of the Java fanatics, and Sun, who have decided to
> tell programmers what is good for them, whether they want to swallow
> that pill or not.
>
> Java is the only major language I use which does not have operator
> overloading. C++, Python, Ruby, C#, and D all have operator overloading.
> Among other things this means that while 1 + 2 in Java is valid, if I
> write a BigInteger Java class I must write: BigInteger a = 1; BigInteger
> b = 2; BigInteger c = a.Add(b); or some such other nonsense rather than
> the completely natural BigInteger c = a + b;.
>
> To say that the lack of operator overloading in Java somehow makes the
> language "better" or "clearer to use" is so ludicrous it needs no
> further comment.
>
> Eventually Java will add operator overloading, since Sun's fanaticism is
> clearly earning them a quick exit into buyout land ( if not IBM today it
> will be someone else tomorrow ). Then everyone from the Java fanatic
> camp will smile and say "wasn't that a brilliant decision Sun made", as
> if it hadn't been made by everyone else ages ago.
>
> Sorry for the non-D related diatribe but someone else started this
> thread and I can't help remarking how stupid a language must be in this
> day and time which does not support operator overloading for ease of
> syntax use.
This has happened before. Somehow Java has this penchant for attracting
odd groupies. Pretty much every feature that Java didn't have was
vilified by zealots until adoption, when all of a sudden it became a
brilliant decision.
Andrei
More information about the Digitalmars-d
mailing list