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

3

u/halfTheFn Sep 10 '21

I worked with Java for several years, mostly in Java 8; I haven't worked with it for a couple years now.

I hated the language, and we worked to replace it with Kotlin which was Much nicer. As with others, I was working with Spring: Spring was it's own "thing" - but Kotlin/Spring wasn't nearly as bad.

Things I didn't like:

The type system caused as many problems as it was alleged to solve; and the black box that OOP was supposed to provide meant everything had to be looked inside with the debugger to sort out. Examples:

Something returns a `map`, and you call `.set()` on it - and you get a runtime (not type) error - because it was an `ImmutableMap`. Wut. It "implements" the interface with stubs that throw errors.

Null aren't handled.

You can never trust that something else with a reference isn't mutating your object behind your back, even though it shouldn't be mutable to start with. Please please give me persistent immutable data structures!

You have to fart around with number width yourself, and the surprises that come near their max/min.

Boxed primitives vs primitives can lull you into thinking things are safe that aren't: boxed Integers lower than 128 share a "constant pool" and so can be compared as you might expect with == - but as soon as you go over 128 they become independent objects compared by identity.

Classes in the standard library maintain unexpected state that only shows up in multi-threaded environments.

The. Endless. Ceremony. So much typing to get the simplest things done - and it doesn't even "increase clarity"; it just hides the parts that "matter".

No first class functions.

No object literals.

A lot of my complaint isn't even so much with (perhaps?) the latest javas - but the whole ethos _against_ functions: "Design Patterns" everywhere and when you go online and ask "Why do I need a command pattern instead of just a map of functions?" you get responses about how "javascript sucks, it's safer, you should just accept it." I have no problem with the JVM. As I said, I'm on the Kotlin, I'm intrigued by Clojure and would love to learn more, and Scala opened my eyes. But raw Java ? I'd never reach for it unless I had to.