What does the word "generic" promise?

| 4 Comments

Bruce Eckel, author of Thinking in Java has a controversial blog entry about generic types in Java 1.5.

I believe that Bruce has largely missed the point of Java's generics, and that the "latent typing" ideas he discusses would take Java in a very unJava-like direction. His post turns into something of a rant, but the crux of it seems to be this:

I feel lied to (by the term generic)

Basically, Bruce had heard about generics in Java 1.5, but had not yet read about them. The use of the word "generic" gave him a very mistaken idea about what this language feature actually entails. And then when he actually sat down to study generics in Java he was sorely disappointed.

I don't want to debate Bruce's other points here. I am curious, however, whether anyone shares Bruce's concern that the term "generic" when applied to Java's parmeterized types, promises something beyond what Java delivers. I haven't read Bruce's books, but he's presumably a pretty smart guy. If he's gotten this confused by the use of the word, I wonder whether others share his confusion. If the term "generic" is confusing, I'll want to avoid it in the next edition of Java in a Nutshell, or at least include a footnote about the potential confusion.

If you're familiar with generics in Java 1.5, and have used a similar facility in another language, your comments are encouraged!

4 Comments

I just want to say - I've never heard the term generics before they were introduced into java. They could have called them templates for all I care. (I have a BS in Computer Science, so I'm not exactly shielded from other languages either).

In c++ generic was orginally designed due to it's static strong type character. I found java's generic is just an ugly wrapper of type cast.

There is little common terminology between computer languages. Until there is some attempt to create shared definitions for words, you pretty much have to use each word as it is defined for the language.

Sun calls it "generics" in Java, so I don't see that you have much choice. You could always add a note that Java generics are closer to Ada and Eiffel generics (typesafe parameterization by type) than they are to C++ generics (macro facility generating closed code).

Actually, I see the generics just like a comfortable way to avoid writing casts and System.Object-based classes. I believe they work very well especially with collections.

I don't know who is right either David or Bruce, and actually I don't care. I'm not interested in religion wars or terminologie issues. The name generic for me is ok, and I think I'm going to use them in the future in a very massive way, even if basically there is no benefit at run-time.


Books

Comprehensive coverage of Ruby 1.8 and 1.9

"The New Most Important Ruby Book"
Peter Cooper,
rubyinside.com

Completely updated for Ajax and Web 2.0

"A must-have reference"
Brendan Eich,
creator of JavaScript

The classic Java quick-reference