This link has been bookmarked by 10 people . It was first bookmarked on 22 Aug 2007, by Navneet Kumar.
-
25 Nov 08
-
22 Aug 07
-
Java Generics use "erasure," which drops everything back to
Objectif you try to say "any type." So when I say<T>, it doesn't really mean "anything" like C++/ADA/Python etc. does, it means "Object." -
generics have no advantage. In fact, it's confusing if you see them used, because you scratch your head and wonder "why does he need a generic here? What is the advantage?" Answer: none.
-
So if we write generic code that actually takes a "type of anything," that type can only be an
Object, and our generic code must only callObjectmethods on it. -
Generics seem to only solve the problem of automatically casting in and out of containers.
-
So generics are really "autocasting."
-
That's the way of the Java world, and we are going to miss out on latent typing (it's actually possible to simulate latent typing using reflection, as I do once or twice in Thinking in Java, but it's messy and much less elegant).
-
-
09 Mar 06
-
16 Dec 05
-
3-10-04 Generics Aren't
-
Would you like to comment?
Join Diigo for a free account, or sign in if you are already a member.