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?
Software Engineering Stack Exchange is a question and answer site for professionals, academics, and students working within the systems development life cycle. It only takes a minute to sign up.Sign up to join this community
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.)