5 ms·
I still can’t see any proof in your posts that using type erasure for generics makes easier to have interop between languages. And I can’t think about any singl
by tigershark 8y ago
I still can’t see any proof in your posts that using type erasure for generics makes easier to have interop between languages.
And I can’t think about any single reason why that should be the case.
Python doesn’t have at all the concept of generics.
Why it should be any more difficult to implement interop between Python and a language with proper generics compared to a language with erased generics?
For Python it will always be an object, and getting the result in Java or C# you will still need to cast it properly.
- pron 8y agoHere's an example: A Clojure list is a Java list, but Clojure is untyped. However, if you create a list of strings in Clojure, you can call any Java method that takes List<String> even though Clojure has no such concept. AFAIK, on the CLR, Python requires special treatment to call such a method. Also, Kotlin's and Java's variance strategy is very different. Nevertheless, Java's generic data structures are reused in Kotlin.
- tigershark 8y agoMmm.. ok, in iron Python you obviously need to specify the generic type that you are passing because it is needed to resolve the correct method, but in Java you wouldn’t. For me it’s a perfectly acceptable compromise if I can specify methods with the same signature and you can avoid passing around Class references to infer the type.
- pron 8y agoWhy do you need to pass around class references? That's exactly what I was saying about doing something wrong. In over 15 years of programming in Java heavily, I don't think I had to do that more than a couple of times.
- noelwelsh 8y agoAdding to the examples, Scala has declaration-site variance while Java has use-site variance. Erased generics allow the two to work together.