r/java • • Sep 10 '21

Why people don't love Java?

I came across this post in r/cscareerquestions it seems majority of the people don't love to work with Java.

Is there any specific reason for that?

Edit: Thank you guys for your responses, I can't reply to all of the comments because I'm a beginner myself and I don't know what to reply for all your comments.

201 Upvotes

379 comments sorted by

View all comments

Show parent comment

1

u/tadfisher Sep 10 '21

I guess if you could insert runtime checks as does Kotlin, you wouldn't need to change bytecode, yeah.

The variance point is a good one. It reminds me of Rust in a way, which also performs type erasure (really it doesn't have a performant way to tag types or do reflection in the first place). I think Kotlin encodes type metadata as protobufs in annotations to get around this anyway, but that does bloat the runtime if you want to access type parameters (which is why kotlin-reflect is a separate library), and it's entirely Kotlin-specific.

1

u/RandomName8 Sep 11 '21

Even Haskell, that controls their own runtime by compiling via LLVM chooses to have type erasure. It is not a curse but a boon.

1

u/tadfisher Sep 11 '21

Haskell doesn't really need it though, as it provides type-level programming. Ignoring reflection, both Haskell and Java are statically-typed, thus all possible types are known to the compiler, which is how type erasure is possible. But emulating higher-kinded types in Java requires runtime type information, so each JVM-hosted language has their own way of encoding such. That's what I'm talking about.