Hacker News new | comments | show | ask | jobs | submit login

> Isn't type erasure one of the reasons there are so many dynamic languages on the JVM?

No and yes.

No, it doesn't really matter for dynamically typed languages (just use Object for generic types).

Yes, it matters for statically typed languages. One of the factors for Scala .NET abondonment was the difficulty in creating a interoperable advanced type system in a fully reified environment.

IMO, full type erasure (like C/C++) is the right way to go. Java erasure is weird only because it didn't do it completely, not because they did it at all.




What do you mean with "full type erasure (like C/C++)"? Afaik if you have RTTI enabled you have full type information available at runtime, even for templates - which is the thing that people usually want when talking about reified generics. Is it about C++ without RTTI? Or about the fact that vector<int> is compiled completely separate from a vector<string> (monomorphization)? I think the latter one is an orthogonal issue to whether type information is available at runtime.


You're right, since C++98, it's has RTTI. Subpar example on my part :/


> No, it doesn't really matter for dynamically typed languages (just use Object for generic types).

At which point any call to the underlying environment fails with a type error. Sorry your List<Object> is not and will never be a List<int>, trying to pass it as one wont do. Either you provide a way to construct a generic type with the right type parameters in the dynamic language or you accept that you can only inter-op with a limited subset of the underlying environment.

Of course that also gets ugly. You now have to deal with the fact that you not only have a List but several incompatible List<T> floating around, adding the contents of two lists suddenly includes the question what sort of list to return, List<Int>,List<Double>,List<Number> or an error? In a type erased context the answer is always the same, you return a List<Object>.


> No, it doesn't really matter for dynamically typed languages (just use Object for generic types).

This line is disproven by all the dynamic languages that happened and failed on the CLR.


Did they fail because they weren't possible to build on top of the CLR, or because people didn't want to use them?




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact

Search: