[1048] in java-interest

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

Re: Overloading & New

daemon@ATHENA.MIT.EDU (Terence John Parr)
Thu Aug 17 18:47:15 1995

Date: Thu, 17 Aug 1995 12:31:44 -0700
From: Terence John Parr <parrt@parr-research.com>
To: parrt@parr-research.com, vizbiz.com!green@vizbiz.com
Cc: francois@coplanet.fr, gary@Intrepid.COM, java-interest@java.sun.com,
        johnm@alumni.EECS.Berkeley.EDU

Hi Anthony.

> In practice, you may want to use templates for performance reasons. 

Yes, given the interface or base class, you can generate even plain
function calls sometimes.  This is a good thing speed-wise.

> Dynamic messages and interfaces both incur runtime costs (which may be
> eliminated in *some* cases with clever optimizations). Oh - and
> they can be good for strong static type checking.

Yes, it's nice to be able to say

List<Pencil> pencils;

so that when you try to do

pencils.add(dog);

you get a static warning.  I agree.

>     Terence> PLEASE: All C++ people please go back to C++ and quit
>     Terence> trying to turn Java into an interpreted C++.  Gawd!!!
>     Terence> This is ridiculous!  Templates are a total nightmare to
>     Terence> implement/get-right in C++.
> 
> True - but I still would like to see a simple parameterized type
> mechanism added to Java.

A simple one could be acceptable, but I'm terrified of the very word 
because of C++ ;)  Gee, they started getting them right in C++ compilers
after how many years?

> I have a lot of experience in this area and
> have found them easy to implement and extremely useful.

You mean to use them to implement programs.  I meant implementing
compiler tools. ;)  Wait..no, you guys actually built your
own language, right?

Parameterized types are a nice concept, but when I see the code bloat
and what it does to the complexity of C++, my knee-jerk reaction
is to say "aaahhh!!!!".  However, templates can be implemented in many
ways.  I guess

List pencils;
pencils.add(dog);

without even a runtime warning could be bad.  Didn't bother me
in Smalltalk though.  Most of the time I have
homogeneous lists.  I just see it as adding much complexity
when it's not absolutely needed (as it is positively needed in C++).
Perhaps I'll try to add templates to our grammar to see how things
would look.  If left as a compile-time check, the runtime wouldn't
be effected.  However, to take advantage of the type information
would require generating different output.

As long as we don't have to use iterators...uh oh...now I've done
it...major jihad started there.  All C++ folks may now commence to saying
how great they are.  In C++ they are essential, in Java/Smalltalk/Objective-C
they are not considered cause you don't need 'em.

> My
> understanding is that the implementation side of Java arrays lay the
> foundation for such a mechanism. 
> 
>     Terence>    If you haven't learned your lesson with C++, you
>     Terence> deserve each other.
> 
> Oh Ter - that hurts! :-)

Sorry...I've got such a big mouth. :)

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