r/AskProgramming • • Mar 20 '25

Why is Java considered bad?

I recently got into programming and chose to begin with Java. I see a lot of experienced programmers calling Java outdated and straight up bad and I can't seem to understand why. The biggest complaint I hear is that Java is verbose and has a lot of boilerplate but besides for getters setters equals and hashcode (which can be done in a split second by IDE's) I haven't really encountered any problems yet. The way I see it, objects and how they interact with each other feels very intuitive. Can anyone shine a light on why Java isn't that good in the grand scheme of things?

226 Upvotes

695 comments sorted by

View all comments

Show parent comments

5

u/senfiaj Mar 20 '25

Also Java has null safety issue. It's one of the major arguments, and one of the reasons of the rise of Kotlin's popularity.

4

u/okay_throwaway_today Mar 20 '25

I feel like Optionals and some other QoL things in Java 8+ have addressed this and, continuing in later releases, a lot of the other more famous criticisms. But of course the benefit of those depends on what version or style the codebase at hand uses, and Java is prominent in a lot of legacy stuff

4

u/Reggienator3 Mar 21 '25 edited Jun 21 '26

Overwritten for privacy

1

u/Necessary-Peanut2491 Mar 21 '25

Optional is nice, but yeah, it doesn't solve the nullability issue. It just makes it Somebody Else's Problem™ at best, but you mostly end up writing slightly different boilerplate. It's just semantic boilerplate now.

And then there's the fun times you'll have when dealing with some third party libraries that have interesting ideas about null. I've seen things that will helpfully throw an NPE for you if you try to read a value that's null, because they've taken an extreme stance of "anything null is invalid" and force their users to follow some cumbersome pattern of calling their helper methods instead.

Looking at you protocol buffers.

2

u/Wonderful-Habit-139 Mar 21 '25

They haven't addressed it because they can still be null, sadly. But they're nicer to use in newer codebases for sure.

2

u/[deleted] Mar 21 '25 edited Mar 23 '25

[removed] — view removed comment

1

u/senfiaj Mar 21 '25

Sorry, but this doesn't seem to be as good as the Kotlin's native implementation. Also what if the Optional itself is returned as null , especially when Java doesn't support ?. operator (as far as I know, please correct me if I'm wrong)?

I'm not a Java developer, but I have experience in Flutter, and the older versions of Dart language had similar null safety problem. It was fixed in later versions, but unfortunately they had to eventually break the backward compatibility by removing the legacy null unsafe support. I wonder why didn't they do this much earlier since Kotlin was around there for many years. They could learn this from Kotlin.

1

u/Particular-Way-8669 Mar 22 '25

The fact that Optionals can be null is complete non issue.

1

u/senfiaj Mar 22 '25

Why?

1

u/Particular-Way-8669 Mar 22 '25 edited Mar 22 '25

Because it can only really happen if you set null into Optional manually or use Optional#of - which would not set it to null but result in NullPointerException during runtime - instead of Optional#ofNullable. You have to introduce it yourself. And when you go on "possibility to do something bad" then you really start running in circles because no language enforces null safety. You have to demand it, in Kotlin via "?" operator too.

1

u/Lumen_Co Mar 20 '25

True. That's one of the things C# does better.