Hi, John,
Glad to see there's someone else that disagrees with Sun's decision not
to use operator overloading. I agree that "saving developers from
themselves" makes very little sense, especially when null pointers (#3)
still exist.
#2 (the ternary operator), I'll chalk up to a difference in opinion.
#3 (null "references"?) I wasn't saying I would like to see the
exception name changed. My point was that references should, by their
very nature, always refer to a valid object. Null (or 0) is not a valid
object; therefore, there should be no such thing as a null reference
exception. Face it, because of the fact that Java "references" can
contain null, they are really poorly disguised pointers.
I say that we do away with all null pointers, so we are really dealing
with true references.
--Tim Sabin
John Gaughan wrote:
>
> Java Guy wrote:
> > There are 3 quirks that I would propose for the "strangest thing about
> > Java":
> > 1) The lack of operator overloading. This was a major step forward
> > (IMnsHO) in C++. Java uses + to indicate addition of numeric primitive
> > types, and "overloads" + to also mean concatenation of String objects.
> > Wouldn't it also be neat to say something like:
> > MyVector<String> a = ...;
> > MyVector<String> b = ...;
> > MyVector<String> c = a + b;
> > Or, code "extraction" into String, and call it - :
> > String str = "abcdefg" - "bcd"; // Yields "aefg"
> > Of course, we would have to code the overload operator methods, just as
> > in C++.
> >
>
> I don't think this is strange, given that Java inherited from C++ but
> tried to be different: specifically, it tried to save developers from
> themselves. Operator overloading was one of the C++ features that was
> often misused, so Sun did not implement it in Java with the exception of
> string concatenation.
>
> I also disagree with their decision. Bad developers will develop bad
> design and bad code no matter what tools are available.
>
> > 2) Keeping around the ternary operator. C programmers knew that it was
> > useful, but very cryptic. If/else is more readable and does the job
> just
> > as well; it only takes longer to code.
> >
>
> I disagree. The ternary operator is a lifesaver in situations where you
> can use expressions but not statements. As soon as I read this I
> immediately thought of Jasper reports: you can give expressions for
> reports bands and cell contents, but not statements. "If" is a
> statement, the ternary operator is not. The Java application I develop
> at work has at least 80 Jasper reports, and each one makes extensive use
> of the ternary operator. These are not simple reports: many of them are
> driven by 200 lines of SQL, have multiple bands, and complex grouping.
> Some may call that archaic or a pain: I call it one of the reasons for
> charging as much as we do per hour for development :-)
>
> The general case for keeping this is integrating code into third-party
> libraries that may only accept expressions.
>
> > 3) If Java is truly Object Oriented, then there are only references,
> and
> > not pointers. C++ made a valiant attempt at this. However, why,
> then, is
> > there an Exception called NullPointerException? I know the answer to
> > this one; it's just that the answer is unacceptable.
> >
>
> Would you rather they named it NullReferenceException?
>
> --
> John Gaughan
>
>