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

1

u/antihemispherist Mar 21 '25

Those are unmodifiable collections, not immutable collections.
You need to have interfaces like ImmutableList (like in Kotlin) for that. Can't be introduced without breaking compatibility in a big way, so it won't happen.

I'd argue that hiding generated code with Lombok is usually not an improvement, and Lombok tends to be overused, because developers overvalue the apparent syntax. I wrote more about that in here.

1

u/svick Mar 21 '25

Those are unmodifiable collections, not immutable collections.

Can you define the word "immutable"?

1

u/ramrug Mar 24 '25 edited Mar 24 '25

An immutable type is a guarantee that no instance of that type can be modified in any way. Ever.

An immutable list interface typically does not even include add/remove methods, and if it does, those methods must create new lists instead of mutating the existing one.

An unmodifiable type does not provide a way for you to modify an instance, but it might still be modified internally. Or you might be able to cast it to a type that is mutable.

(Read-only is probably a better term than unmodifiable)

1

u/lordheart Mar 21 '25

Ah that is true, but you can use guava then I believe.

I’d argue that just because some people overuse it doesn’t mean hidden code is bad. Libraries are also “hidden” code.

Getters and setter, equals, hash, to string, are all better generated for the most part. They remain correct as the class is modified.

If a getter or setter is manually written then it’s easy to see which ones actually have some extra functionality instead of looking at a hug list of them and wondering if maybe one or two have some specific functionality.

If you are using spring, there are annotations for a lot of common validations so checking specifically in the constructor is not necessary. (Not even spring specific but it’s what I do mostly when I have to use Java)

Javas generics are definitely not the greatest, but a far sight better than none. I have to program in abab as well and it makes me appreciate Java more.

Abab “generics” is marking something as any, and then using quasi reflection to look for field names. It’s horrendous.

Rust also has macros to template code generation, a lot of languages move common functionality out like that some way because that code just slows down reading.