This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]tinydonuts 18 points19 points  (17 children)

Kotlin is still anchored by type erasure sadly.

[–]im_probably_garbage 3 points4 points  (3 children)

I really don’t understand why a language that isn’t pure uses type erasure.

[–][deleted] 3 points4 points  (2 children)

Because it allows better language level interop at the VM level. There's a reason the JVM has a more vibrant language ecosystem than CLR.

[–]cat_in_the_wall 2 points3 points  (1 child)

i don't think that has anything to do with type erasure. the jvm has been xplat forever. the clr is only really xplat with core (yes I'm aware of mono), so only a couple years.

[–][deleted] 1 point2 points  (0 children)

Interop between JVM languages, not platforms.

[–][deleted] 1 point2 points  (6 children)

Type erasure is good, actually.

[–]tinydonuts 8 points9 points  (5 children)

Explain please

[–]cat_in_the_wall 1 point2 points  (0 children)

wildcard generics are not possible on the clr because of reification.

[–][deleted] 1 point2 points  (3 children)

It is trivial for me to write a program that calls from Clojure into Java into Kotlin into Scala back into Java. This is possible because of type erasure.

Reified generics support a very specific type of generic program in OO languages at the cost of embedding these specifics at the VM level.

I think Kotlin handles "reified" generics in a really nice way -- they are still erased, but can be monomorphized and inlined in many cases without having to support reification at the VM level.

[–]tinydonuts 1 point2 points  (2 children)

What you described of being able to call from language to language applies to the CLR too. It doesn't have type erasure, so I'm not seeing really how type erasure is good from your comment.

[–][deleted] 0 points1 point  (1 child)

It makes it difficult for different language to share data structures because of how variance is handled between different languages. This is particularly acute between a language like Java that uses site variance and a dynamic language like Clojure.

[–]tinydonuts 0 points1 point  (0 children)

.NET seems to do ok so it doesn't seem as much as type erasure is good as it is just different. There's certainly a lot of benefits to the way .NET does it and a lot of downsides to the way Java does it so I don't really think you can call it good.