I think that the problem with Java is not that they are implemented with type erasure (many functional languages do the same and monomorphize only when optimizing), the issue is that this implementation detail is a leaky abstraction in Java.
Re:Java Generics Are Turing Complete
by MereInterest on Thursday May 26, 2016 @11:04PM
(#11783620)
Type erasure also makes some forms of function overloading impossible.
void func(List<ClassA> list);
void func(List<ClassB> list);
Using type erasure, I cannot specify functions that are overloaded based on the generic type of an argument. To the runtime, both of these accept an argument of type List<Object>, and so it is ambiguous which one to call.In C++, which does not use type erasure, this sort of function overloading works as expected.
Not to mention, having type erasure made them backwards compatible with non-generic implementations. I don't think it would have been acceptable to break old Java code or introduce an entirely new collections library like .Net did.
Re:Java Generics Are Turing Complete
by eternalban on Thursday May 26, 2016 @01:22PM
(#11779762)
Pretty sure the scope of the generic stage is the compilation unit.
So, claiming type erasure making generic useless is a false argument.