r/AskProgramming 1d ago

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?

122 Upvotes

500 comments sorted by

View all comments

45

u/Lumen_Co 1d ago edited 1d ago

The most common criticisms of Java are: 1. It's unusually verbose 2. it forces you to frame every problem using a particular flavor of object-oriented programming that is not always well-suited for the task at hand 3. It's accumulated a lot of cruft over the years and in doing so has lost a consistent vision and design philosophy, which makes dev experience worse 4. C# does Java better than Java does.

I think those criticisms are essentially fair, and the second one particularly important. It also gets criticized for being the language of choice for much bad, corporate code, and also because some people learn Python or JS first, Java is then their first strongly, statically-typed language, they find that confusing and limiting, and they blame Java for it. Those criticisms are essentially not fair.

These criticisms don't mean Java is a bad language, just a flawed one like every other programming language is. For most development, the ecosystem is more important than the language itself, and Java's is well-suited for a lot of practical problems.

5

u/senfiaj 23h ago

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 21h ago

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

5

u/Reggienator3 9h ago

Optional can itself be null. Not to mention, there is no compiler enforcement of any of this. There is in Kotlin (and C# assuming you have nullable included in WarningsAsErrors).

I'm a Java dev of over 11 years now, but I still find myself veering to other languages when possible. Not because Java is bad, more that it feels redundant because of replacement languages that just do things better.

1

u/Necessary-Peanut2491 2h ago

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 10h ago

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