Lambda the Ultimate

inactiveTopic Genericity in Java
started 9/15/2000; 2:07:36 PM - last post 9/20/2000; 4:19:16 AM
Ehud Lamm - Genericity in Java  blueArrow
9/15/2000; 2:07:36 PM (reads: 479, responses: 2)
Genericity in Java
This issue comes up often. People claim that the lack of generic programming facilites in Java is bad. With this I totally agree. I think generics are useful. See our survey.

There are several proposals for addition of generics to Java. Some more to my tastes than others. This page links to the most prominent ones (I think).


Naturally, some people argue as follows:

A. Java is the perfect language

B. Java lacks genericity

ergo

C. Genericity is not important.

I am just having a hard time accepting A as a premise...
Posted to "" by Ehud Lamm on 9/15/00; 2:10:19 PM

Chris Rathman - Re: Genericity in Java  blueArrow
9/17/2000; 10:35:44 AM (reads: 502, responses: 1)
A. Java is the perfect language
I haven't really run across any Java programmers who hold to this view, really being an absurdity with all the well known problems in the language. There are some, however, who will argue that the tradeoffs of the language provide the right feature set with the least amount of complications.

B. Java lacks genericity
Given that Java does not have generics, this is a well known proposition. Interestingly, Gosling did consider implementing generics early in the life of the project (prior to it becoming popular), but decided that the resource constraints prevent Sun from integrating generics into the language. Of course, generics would have been a whole lot easier to implement at that stage of the project than they are now, given the number of libraries and users.

C. Genericity is not important.
It's not really a matter of generics being totally insignificant. It's a question of return on investment. Does introducing generics into the language solve a problem that absolutely has to be solved, and can it be done without cost and complications.

For my money, the most immediate benefit of generics is to be found in the collection classes (though they can be used in any number of places). Collections in Java are much harder to use and less featurefull than they are in languages such as Smalltalk and Python. Indeed, the dynamic OO languages are head and shoulders above the capabilities of static type checking in Java. The funny thing is that Java collections effectively have to downcast every time an Object is retrieved from a collection - thus eliminating the very advantage of compile time static type checking.

One thing of note, the Java Collections have already gone through one major rewrite - JDK 1.2 collections. I think some in the Java community have the feeling that we don't need to introduce generics into the language and then have the API drastically rewritten once again. I think this may be a large measure of the hesitancy involved in adopting the GJ solution.

Ehud Lamm - Re: Genericity in Java  blueArrow
9/20/2000; 4:19:16 AM (reads: 532, responses: 0)
My poor attempts of humor...


Of course, I don't agree about the tradeoff reasoning here. First - I really like generic programing. Second: You have to factor in the readability of the code. Generic code (in good languages) is more readable than complicated type hierarchies/casting etc.