Constraints while designing the Java generics

Posted by Andrea on Programmers See other posts from Programmers or by Andrea
Published on 2012-10-05T15:25:44Z Indexed on 2012/10/05 15:52 UTC
Read the original article Hit count: 279

Filed under:
|
|

Java generics look quite different from those available in Scala, although both were designed by Martin Odersky. From my point of view, the design of generics in Java is worse, for instance:

  • there is no possibility to specify variance
  • one can get around the previous limitation by using wildcards, but this means the burden of specifying variance goes on the caller instead of the library designer
  • one cannot use a type constructor in generics

What were the constraints in Java that forced Odersky to design this mechanism for generics instead of the more flexible one he devised for Scala? Was he just savvier a few years later or there were actual limitations due to Java?

© Programmers or respective owner

Related posts about java

Related posts about scala