and why the hell...

Robert S. Thau rst@ai.mit.edu
Mon, 10 Mar 2003 00:07:57 -0500 (EST)


Joe Barrera wrote:
 > > ... doesn't Java have Generics? (Templates?)
 > > Not having generics makes things so awkard, and
 > > makes it too easy to write type-unsafe code.
 > > Jeez. I think that's the only think I miss from C++.

There will be templates in JDK 1.5; there's a detailed spec of the
extension on java.sun.com somewhere.  It's just about all in the
compiler, BTW; what exists in the JVM at runtime are "erased" types
which, in effect, treat all the template parameters as Object, so the
templating is effectively (to first order) syntactic sugar for the
casts you'd have to write in Java-as-it-is.  Which is how they do
back-compatibility for things like collections; there's a full
templated collections library whose "erased" types are the Java 1.4
collections.

rst