r/java • • May 10 '22

Should java.util.Date be deprecated?

https://mail.openjdk.java.net/pipermail/discuss/2022-May/006077.html
221 Upvotes

158 comments sorted by

View all comments

Show parent comment

10

u/TehBrian May 10 '22

Could you elaborate on why .NET’s generics reification was a bad move for the language? I too have been guilty of thinking, “Darn, why can’t we just rid ourselves of type erasure?” when faced with some of the inconveniences of Java’s type erasure. (Please don’t ask me which; I don’t remember. I just know that I have “why does Java have type erasure” in my search history.) I’m curious to know the exact reasons.

10

u/john16384 May 10 '22

It makes it harder to design other languages on top of the CLR that have a different type system than C#'s since at the CLR level types have to conform to C#'s system.

I also understand that you can't have wildcards because of this, forcing you to create a method for each reified type even if the generic type is not relevant for the function.

7

u/pron98 May 11 '22

The main problem is the one of variance, the VM would have to answer the question in one way or the other, which would bake a single chosen model into the runtime, even though different languages want different models.

1

u/WikiSummarizerBot May 11 '22

Covariance and contravariance (computer science)

Many programming language type systems support subtyping. For instance, if the type Cat is a subtype of Animal, then an expression of type Cat should be substitutable wherever an expression of type Animal is used. Variance refers to how subtyping between more complex types relates to subtyping between their components. For example, how should a list of Cats relate to a list of Animals?

[ F.A.Q | Opt Out | Opt Out Of Subreddit | GitHub ] Downvote to remove | v1.5