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

8

u/backelie May 21 '20

Pre-generics Java was a shit language.

0

u/[deleted] May 21 '20

[deleted]

4

u/Ayfid May 21 '20

Generics are still shit today in Java.

3

u/DetriusXii May 21 '20

Could you explain why they're shit in Java?

3

u/florinp May 21 '20

Type erasure at runtime for a language that use parametric polymorphism with runtime support

6

u/DetriusXii May 21 '20

Type erasure at runtime for a language that use parametric polymorphism with runtime support

Haskell has type erasure too. It seems that most languages that want to implement higher kinded types needs to have type erasure. There are no languages with reified types and with higher kinded types.

2

u/flatfinger May 21 '20

What do you mean "higher kinded types"? The .NET framework, and languages targeting it, use reified generics but also support covariant and contravariant generic interfaces.

2

u/DetriusXii May 21 '20

Higher kinded types are generic types that can box other types. Haskell and Scala support higher kinded types whereas .NET only support concrete types. Instead of only being able to pass a function void doSomething<A>(List<A> list) into a function, in Haskell and Scala, a function can be declared as void doSomething<M<_>, A>(M<A> list) where M can be any type of container, including a List<_>.

1

u/kprotty May 21 '20

If I understand that definition of HKT correctly, then could Ziglang be considered as one with reified generics without type erasure?

fn doSomething(comptime M: var, comptime A: type, list: M(A)) void {}

1

u/DetriusXii May 22 '20

If Zig allows that, then you have higher kinded types. I'm not fully sure that zig's types are reified from the examples provided. Are you able to perform a cast of a function parameter into a generic type? C# allows that. Java does not. C# allows bool compare<Q>(object o) { return o instanceof Q; }

→ More replies (0)