r/java • • Dec 29 '21

Why everyone hates Java?

I dont understand why java is one of the most dreaded lenguages. Java got fantastics frameworks and libraries to work with it. I dont know if im skipping something or I dont work enough with Java because I like java. What do you think??

Here is the Stack Overflow Survey

268 Upvotes

367 comments sorted by

View all comments

33

u/atpeters Dec 30 '21 edited Dec 30 '21

The four main complaints I've heard from some people are:

  1. Generics

  2. Null

  3. It's not functional

  4. Boilerplate

These are people that want to work with closure, erlang, Haskell, etc instead.

Personally I don't mind Java much except for working with JSON due to generics and cast checking. Admittedly I'm stuck in JDK 8 and I don't know if that has been improved upon.

0

u/[deleted] Dec 30 '21

[deleted]

16

u/fufucum Dec 30 '21

Agreed, plus who cares about boilerplate code? always use auto-generation, don't write getter setter by your hand,

7

u/monbis Dec 30 '21

I kind of agree, but there are two issues I see with boilerplate:

  1. Changes need to be done in several places, some of which your IDE may do for you, but sometimes you need to do

  2. More visual and cognitive clutter when reading the code

4

u/MaName678 Dec 30 '21

Or use Lombok <3

7

u/devcexx Dec 30 '21

Yes, the solution for a language is to let a third-party library to do what the compiler can't by hacking into each different commercial Java compiler and forcibly modify the AST of each file in your project because of the lack of an external interface for doing so, yes seems reasonable.

3

u/MaName678 Dec 30 '21

Chill, Java isnt perfect and neither is Lombok as a solution, but sometimes you must work with whats given XD.

Edit: BTW, I love the way C# handles this getter and setter matter

4

u/devcexx Dec 30 '21

Yeah ik, sorry I was not attempting to be aggressive, just adding some irony <3.

→ More replies (1)

4

u/ivancea Dec 30 '21

Comparing Java with JS or Python is like comparing oranges with lemons.

If you compare it with something similar, like C#, you see you have a lot of flexibility, and those problems doesn't exist. And it's also a top used language

0

u/[deleted] Dec 30 '21

[deleted]

4

u/ivancea Dec 30 '21

And Java and JS are languages. But little people eat lemons

Edit: little people => few people. I don't know what little people eats 😬

3

u/m02ph3u5 Dec 30 '21

We eat little food

→ More replies (25)

3

u/minato3421 Dec 31 '21

Working with Json in Java is a pain in the ass. I recently had to write a Go service in my current organization and was surprised to see how easy it was to handle Json data in Golang.

3

u/ConstructedNewt Dec 30 '21 edited Dec 30 '21

Records take away so much boilerplate. Sadly classes are still expected to be 1 class per file, so you har some one-line files (or nest them)

Null is a real problem, but, like generics (and pain points on them), it's mostly the designers fault. All though language can promote bad/ good habits

3 is just stupid to complain about. Like, sure... use something else idc

Jackson JSON ObjectMapper to a record type is pretty simple, but hasn't changed much (since java 8) although I'm unsure about Snake case names

Edit: @JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class)

4

u/Muoniurn Dec 30 '21

Sadly classes are still expected to be 1 class per file,

That’s only public classes. You can put non-public records outside your public class.

→ More replies (2)

3

u/deinlandel Dec 30 '21

You can just use Kotlin and fix all of these while maintaining full compatibility with an existing codebase and all JVM libraries and frameworks.

That's actually what is great about Java Ecosystem: you are not limited by one language.

→ More replies (1)
→ More replies (10)