Search the web
Sign In
New User? Sign Up
Java_Official · Java SE . EE . ME . AJAX . Web services
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Real people. Real stories. See how Yahoo! Groups impacts members worldwide.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Joshua Bloch on Strangeness in the Java Platform   Message List  
Reply | Forward Message #31756 of 32218 |
Re: [Java] Joshua Bloch on Strangeness in the Java Platform

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
>
>



Thu Nov 13, 2008 10:33 pm

mmjavaguy
Offline Offline
Send Email Send Email

Forward
Message #31756 of 32218 |
Expand Messages Author Sort by Date

Joshua Bloch gives an interesting interview (http://java.sun.com/developer/technicalArticles/Interviews/bloch_effec tive_08_qa.html) on java.sun.com, promoting...
zorry11111111
Offline
Oct 29, 2008
9:56 pm

Despite what many Java gurus will say, Java inherits a lot from C and C++. One of the things is that all numeric types are signed by default. So, in Java, int...
Java Guy
mmjavaguy
Offline Send Email
Oct 30, 2008
6:24 pm

Well, I have read your reply below, Tim. And I would like to know the answer for question 3 about the NullPointerException. Can you elaborate more ? Thank you...
tantan677
Offline Send Email
Nov 7, 2008
9:29 pm

Sure thing. You want to keep me on my "high horse", do you? ;-) Object Orientedness consists of a network of objects, which are combinations of data and...
Java Guy
mmjavaguy
Offline Send Email
Nov 10, 2008
7:27 pm

... 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....
John Gaughan
john23874
Offline Send Email
Nov 13, 2008
9:04 pm

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"...
Java Guy
mmjavaguy
Offline Send Email
Nov 14, 2008
6:23 pm

... The problem with eliminating null references is that you would have to set the value of any variable where it was declared. That would prevent people from...
David Kramer
dj_segfault_...
Offline Send Email
Nov 17, 2008
11:19 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help