r/programming • • May 21 '20

Java programming language celebrates 25 years

https://www.infoworld.com/article/3544229/java-programming-language-celebrates-25-years.html
95 Upvotes

73 comments sorted by

View all comments

Show parent comments

3

u/DetriusXii May 21 '20

Could you explain why they're shit in Java?

4

u/Ayfid May 21 '20

https://en.wikipedia.org/wiki/Comparison_of_C_Sharp_and_Java#Generics

This is the best comparison of the pros and cons of how Java decided to implement generics vs a sensible way of doing it that I have seen.

Most notably, the comparison table in the "Type erasure versus reified generics" section.

1

u/DetriusXii May 21 '20

See my post to florinp. But it seems that reified generics don't lead to higher kinded types. F# doesn't have them and I can't tell if F* does

2

u/Ayfid May 22 '20 edited May 22 '20

Type erasure vs reification is entirely orthogonal to HKTs.

HKTs are a superset of generics - generics are a limited form of HKTs. Neither type erasure nor reification "lead to" HKTs. They are an implementation detail of generics and both can be built upon to build more expressive forms of HKTs.

Your statement sounds like an argument you have heard elsewhere but don't really understand. It is non sequitur.

Nor does it in any way address any of the numerous problems with erasure, as detailed in the above wiki.

2

u/DetriusXii May 22 '20

Show me a language that has both reified generics and higher kinded types.

2

u/Ayfid May 22 '20

.NET is the only platform that uses reification, and it does have higher kinded types; it has generics, which are HKTs. It does not have the more expressive forms of HKTs (e.g. More expressive type constructors as you find in many functional languages) for many reasons which have nothing at all to do with its types being reified. There are RFC proposals to extend C# with more advanced HKTs and they do not propose making changes to reification - because reification is no impediment to expanding generics.

Rust also has HKTs proposals which also do not require it move away from monomorphisation (which is essentially reification at compile time).

Java does not have HKTs beyond what C# has. It's generics are no more expressive than C#'s.

What point are you trying to make here? You either don't appear to have one, or you have no idea what higher kinded types actually are.

You might as well be demanding that I provide you with flying pigs else you will conclude that unicorns are real. Your demand has no bearing on the topic here.