[1787] in java-interest

home help back first fref pref prev next nref lref last post

Re: A few queries...

daemon@ATHENA.MIT.EDU (Arthur van Hoff)
Sat Sep 16 23:49:24 1995

Date: Sat, 16 Sep 1995 12:27:37 -0800 (PDT)
From: Arthur van Hoff <Arthur.Vanhoff@Eng.Sun.COM>
Reply-To: Arthur van Hoff <Arthur.Vanhoff@Eng.Sun.COM>
To: Llew Mason <mason_l@ee.uwa.edu.au>
Cc: java-interest@java.Eng.Sun.COM



Hi Llew,

> 1)   Pass-by-value vs pass-by-reference vs pass-by-const-reference
> 
>   As far as I could tell this wasn't discussed in any of the provided
> documention.  Java currently passes class arguments by non-const reference. 

Right.

> I assume that the currently reserved const keyword will allow argument
> passing by const reference eventually.  

Maybe. const in C++ is very broken so we decided not to confused anyone
and use final instead.

> I can't see any point in Java ever providing pass-by-value support.

Unlikely.

>   Why was argument passing by non-const reference chosen as the default? 

Because it is most useful?

> This seems to be a dangerous practice and inconsistent with Java's efforts
> at removing unsafe practices from the C++ language. (removal of pointers was
> a good start)

I'm not sure the alternative would have been pleasant either. You would end
up doing a lot of copying if the default was const reference.

> 2)   Meta-classes (template classes for those unfortunate C++ people)
> 
>   There seems to be no way to implement meta-classes within Java.  The
> interface mechanism allows for class methods to operate on any class which
> implements a particular interface, but cannot guarantee the homogeneity of
> instantiated classes.  

We have been thinking about parameterized types. C++ templates are so broken
that we definitely won't add those.

> This makes usage of classes like Vector unsafe (not
> to mention inelegant) since all elements need to be typecast to the required
> type upon extraction.

You are right that Vector is not elegant, but it does the job.

> 3)   Operator overloading
> 
>   Why was this omitted from the Java language?  

Because it makes programs unreadable. Have you been following the discussion
about overloading ".". Soon you will be able to overload the " " (space)
operator (currently string concatenation).

> This is one of the 'neat'
> features of languages like C++. (although I'd prefer overloaded operator
> support like that provided by ML, where new operators can be defined and
> operator precedence can be redefined)

I strongly disagree. Operator overloading makes programs confusing. You first
have to learn the authors use of operators and how they are

>   Web applets would rarely require operator overloading, but if Java is
> intended to be used for any serious development where mathematical classes
> are required then it quickly becomes unwieldy.

Java can't solve all problems for everyone and remain simple.

>   Specifying complex numbers as z.mul(z).plus(c) for Mandelbrot generation
> is ugly compared with z = z * z + c.  Reading code consisting of operations
> on complex number, vector, matrix and tensor classes becomes almost
> impossible without overloaded operators being defined for these classes.
>   I admit that operator overloading can be abused, but then so can function
> naming.

I believe that operatore can and will be abused and should therefore not be
part of the language. With the absense of typedes, macros, and operator
overloading Java is a clear unambiguous language. A piece of code, even
out of context makes sense.

> 4)   AWT class package DisplayItem class
> 
>   Why is the DisplayItem class inherited from the Browser.Observable class?
> I would think that the base GUI package should not take inheritance from
> specific application classes. (Like the HotJava application)

That has been fixed in the beta release.

> Overall I'm quite impressed with what I've seen of Java.  

Thanks.

> With native
> machine-code compiler support, meta-classes and operator overloading I see
> no reason why Java couldn't become as popular as C++.

In my opinion, operator overloading and templates is what makes C++ suck.
I don't think we should make the same mistakes.

Have fun,

	Arthur van Hoff


-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post