I liked the discussion at Differences in Generics, and was wondering whether there were any languages that used this feature particularly well.
I really dislike Java’s List<? extends Foo> for a List of things that are Liskov-substitutable for Foo. Why can’t List<Foo> cover that?
And honestly, Comparable<? super Bar>?
I also can’t remember for the life of my why you should never return an Array of generics:
public T[] getAll<T>() { ... }
I never liked templates in C++, but that was mostly because none of the compilers could ever spit out a remotely meaningful error message for them. One time I actually did a make realclean && make 17 times to get something to compile; I never did figure out why the 17th time was the charm.
So, who actually likes using generics in their pet language?
Haskell implements type-constructor parameterisation (generics, or parametric polymorphism) quite well. So does Scala (although it needs a bit of hand-holding sometimes).
Both of these languages have higher-kinded types (a.k.a. abstract type constructors, or type-constructor polymorphism, or higher-order polymorphism).
See here: Generics of a Higher Kind