Why do generics in Scala have erased types, and are not reifiable?

Is it due to lack of support from the JVM or for compatibility with Java libraries? What are the advantages in general of having generics as reifiable?

  • it is worth noting that Scala versions prior to 2.7.1 had one of target platforms Java ME CLDC which in turn has pretty strong resource limitations and uses err quite unorthodox VM ("KVM")
    – gnat
    Nov 21, 2012 at 12:19

1 Answer 1


These two are only indirectly related.

Scala chose to run on the JVM to leverage the portability and the huge amount of libraries and frameworks that this buys you. This gave it a head start over many other fashionable new languages, and it may also have been a smart move culturally: although many new form of expression are possible in the language, many existing Java programmers liked the fact that the language was more powerful, but not quite entirely unlike Java, and started using the language early.

The price to pay for this is that you have to abide by the limitations of the underlying VM, and yes, among others that means no reified generic types. Time will tell whether the trade-off was worth it or whether breaking with tradition more radically would have been better in the long run. (Note that a goal of Java itself was "to drag about half of C++ programmers about halfway over to Common Lisp" (Guy Steele), which meant that reusing the old C-like syntax was necessary to catch their attention. Perhaps history is repeating itself.)

  • 1
    +1 for the very interesting quote: "to drag about half of C++ programmers about halfway over to Common Lisp". It would be interesting to understand if today's C++ programmers that do not like Java have similar feelings towards Lisp.
    – Giorgio
    Nov 21, 2012 at 16:40
  • I am sorry but I did not understand the line - "to drag about half of C++ programmers about halfway over to Common Lisp"
    – Jatin
    Nov 21, 2012 at 17:07
  • 3
    @Jatin: My interpretation is: "You cannot get all C++ programmers to adopt Common Lisp, but you can get half of them to adopt a language that lies between C++ and Common Lisp."
    – Giorgio
    Nov 21, 2012 at 17:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.