Why is type erasure concept being used so widely?
My question is mainly about Scala, but since in the end it's still using
JVM with its peculiarities, I also put the java tag.
The more I use parameterized types, the more often the aforementioned
question arises. Type erasure brings so much inconvenience (pattern
matching like case x: A[B] becomes impossible and so on) and there are
rather heavy runtime reflection-based workarounds involving extra objects
carrying type information in runtime, so I'm (from my user point of view
and just of plain curiosity) wondering what decisions did lead to the
current lie of the land.
Is carrying complete type everywhere up to runtime information too
complicated? Or maybe there are not so much use cases for it so it isn't
just being needed that often? Anyway, what are pros and cons of type
erasure?
No comments:
Post a Comment