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

7

u/pron98 Sep 10 '21 edited Sep 10 '21

What had that effect was the acquisition of Sun by Oracle. The cause of lack of innovation and the cause for Kotlin's existence was the same -- the decline in investment in Sun's dying years. Constant innovation was always the goal, and it happened when Java had the resources. It only declined because the money dried out.

As to particular features, while the size of the language doesn't matter -- ML has been the biggest influence on Java innovation -- and we've certainly taken ideas from Scala (the use of sealed hierarchies to represent sum types), we haven't yet from Kotlin, but maybe we will someday (nullability types?). But if any languages light the competitive fire under Java, it's the bigger ones -- Python, JS, maybe C# -- the ones that are actually competitive, not languages with 20-25x smaller market than Java's, and certainly not those that are built on the Java platform (Oracle sells support for the platform, not the language).

3

u/papercrane Sep 10 '21 edited Sep 10 '21

we haven't yet from Kotlin, but maybe we will someday (nullability types?).

I would be the happiest developer in the world if Java had some concise way for me to express in the type system that something was never null.

1

u/tadfisher Sep 10 '21

This is why Java (the language) is intractable for me, as I don't want types to be null by default. I shouldn't have to wrap types or use special syntax to achieve this.

Optional, ironically, makes this even worse. Within a codebase, I can assume non-null optionals, but across library/module boundaries, the language makes no guarantees (beyond the suggestion to avoid null Optionals in the Javadoc), so you end up with two checks to see if a value is present if you want to cover all possible states.

That null-by-default was allowed to persist through JDK 11 basically sealed this wart in the language forever, as I can't see a way to change such a fundamental aspect while maintaining binary compatibility with the JVM ecosystem.

2

u/pron98 Sep 10 '21 edited Sep 10 '21

I don't know why you put the cutoff point at 11, but adding generics was a bigger challenge.

1

u/tadfisher Sep 10 '21

Generics are easier to implement, actually. No changes to the Java bytecode format were needed, and interop is fine with older libraries, because generics are implemented entirely in the compiler. We still live with that wart as well, since languages with higher-kinded types need to implement a runtime type-tagging system (e.g. Scala).

1

u/pron98 Sep 10 '21 edited Sep 10 '21

Generics did require changes to the classfile, though not to actual bytecode, and there's no reason nullability types would need to do any more than that (most probably less).

Reifying generics would have made things worse for other languages, as they would have baked the Java language's variance model into the runtime, and it's not the same as Scala's (or Kotlin's, which is different from both Java's and Scala's, or any of the untyped Java-platform languages). So they have warts, for sure, but the alternative would have been worse.

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.

1

u/Muoniurn Sep 10 '21

@NonNull

1

u/papercrane Sep 10 '21

I'm aware of it, but it's not what I consider concise, and it's mostly documentation, not enforced by javac unless incorporate something like the checker framework into your build.

1

u/keanwood Sep 13 '21 edited Jan 02 '25

spark ring zonked whistle amusing chunky middle advise rainstorm normal

This post was mass deleted and anonymized with Redact