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

542

u/thomascgalvin Sep 10 '21

The people posting to that sub are typically young, and probably have more experience with Javascript than anything else.

Compared to JS, Java can feel heavy and constricting. Lots of boilerplate, a type system that's strictly enforced by the compiler, and so on.

It isn't until you have some real-world experience, with code spread out across dozens or hundreds of files, that you realize the "limitations" of Java are actually meant to prevent you from blowing your own foot off.

0

u/[deleted] Sep 10 '21

[deleted]

-2

u/[deleted] Sep 10 '21

system

I tried kotlin with spring... I'll say pass to that because it adds so much more boilerplate because of null safety stuff... I have to declare everything private lateinit var property: Type and so on... feels more verbose than java

0

u/[deleted] Sep 10 '21

[deleted]

4

u/[deleted] Sep 10 '21

tell me more

15

u/cjbooms Sep 10 '21

Assume he means constructor injection with vals. Works for Spring DI and config classes. That'll get rid of all your mutable lateinit types. Constructor injection will improve a Spring Java code base too, it's a much better paradigm

1

u/[deleted] Sep 10 '21

I don't always need constructor injection... I prefer it but can't use it in many cases due to early injection and cyclic dependencies...

5

u/loutr Sep 10 '21

Cyclic dependencies should be avoided. If it is not possible, lateinit is actually helpful because it clearly indicates that the binding won't be made during instantiation.

1

u/[deleted] Sep 10 '21

Agree. Now my service has dependencies of another 26 services (counted them right now) in a big app..probably could reduce that to 15 but now I still have to type 15 times 'lateinit var serviceA: Type' ... Java is less verbose in this case.

In the other case where constructor injection is possible... Java+lombok wins again.. just declare all fields and add @AllArgsConstructor to the service class

8

u/BestUsernameLeft Sep 10 '21

Yeah, @AllArgsConstructor is a great way to disguise the fact that the design is complete shit.

→ More replies (0)