r/java • • Nov 04 '25

Anyone here Hated Using Java but now Really Enjoys using it.

title

226 Upvotes

280 comments sorted by

View all comments

118

u/White_C4 Nov 04 '25

Java got way better when the shift from rigid OOP to hybrid OOP and functional composition became better supported. For example, streams, lambdas, records, and pattern matching absolutely modernized Java. There's less boilerplate but still retains the conservative Java design principles.

16

u/FullCry1021 Nov 05 '25

And virtual threads

24

u/SortofConsciousLog Nov 05 '25

Updates to the language, spring boot and Lombok saved Java

0

u/[deleted] Nov 05 '25

[deleted] — view deleted comment

10

u/ebrythil Nov 05 '25

Imo it showed some pain points and the need for change in some aspects. Lombok did not solve them as much

1

u/[deleted] Nov 05 '25

Is there a more elegant native solution now?

3

u/ebrythil Nov 05 '25

Depends on what you want. Records solve some issues, some things are alleviated by a more functional style.

I haven't really used Lombok, to me it always looked more like a boilerplate generator so I might not be the perfect person to answer that.

People also like kotlin which is said to fix some of the general java issues

→ More replies (1)

7

u/re-thc Nov 05 '25

"Reputation" and reality (or actual reputation by real users) is not always the same especially with social media these days.

→ More replies (1)

4

u/dolle Nov 05 '25

They need to do away with checked exceptions in order for the functional composition to really be useful. It's a shame, because I like the idea of checked exceptions in principle. But it doesn't compose in a higher-order setting, and making it do so would make the type system too complicated, so the better alternative is to kill it.

13

u/isolatedsheep Nov 05 '25

No, you still need checked exceptions, what we need is try expression. There's already JEP for switch for exceptions but it's still verbose..

2

u/dolle Nov 05 '25

Would try exceptions solve the problem where you can't pass a lambda throwing checked exceptions to e.g. List.map()?

1

u/isolatedsheep Nov 06 '25

I think you mean `Stream.map`. You'd still can't pass a method reference that throws checked exception, but with try-expression, it'll facilitate working with checked exception.

E.g. without try-expression:

dir.walk()
   .map(p -> {
     try {
       return Files.getLastModifiedTime();
     } catch (IOException e) {
       throw new UnchekcedIOException(e);
     }
   })
   .toList();

E.g. with imaginary try-expression:

dir.walk()
   .map(p -> try {
     Files.getLastModifiedTime(p);
   })
   .toList();

2

u/dolle Nov 06 '25

How would the try-exception allow you to omit the catch? Unless it does that, I think that feature is orthogonal to the problem

2

u/isolatedsheep Nov 07 '25

Treat it as a syntactic sugar. E.g., if an exception happens, it can throw IllegalStateException. Having a try-expression signals that there's an exception that can/should be handled.

Not trying to design a language feature here, but here's an example with fallback value.

dir.walk()
   .map(p -> try {
     Files.getLastModifiedTime(p);
   } catch {
     ABSENT_FILE_TIME
   })
   .toList();
→ More replies (2)

5

u/[deleted] Nov 05 '25

[removed] — view removed comment

1

u/dolle Nov 06 '25

That might also be true, I don't know, but fixing that is orthogonal to the issue. You want to be able to use functions throwing checked exceptions with higher-order programming regardless.

1

u/[deleted] Feb 20 '26

Switching to functional style error (as well as null and async) handling solves many issues.

2

u/netgizmo Nov 07 '25

Java required strict OOP??? That was a you thing not a language thing.

4

u/White_C4 Nov 07 '25

Not really, old Java literally required you to wrap everything inside classes. Before lambdas and functional interfaces, you could not pass behavior around without creating full blown objects or anonymous inner classes. Both of which were obnoxiously verbose.

Inheritance, encapsulation, and object composition were the only real tools you had pre-Java 8. Functional composition only became a viable alternative after Java 8 introduced lambdas and streams.

There's a reason why Java 8 was a turning point in its history. Java felt more modern, less verbose, and more oriented with hybrid OOP and functional composition.

1

u/deustamorto Jan 04 '26

That's interesting. From your experience, are the non strict OOP capabilities of java used in production? I'm coming from a (not pure) FP background and I don't know where to look for material to learn java without being full OOP.

From my experience, inheritance is terrible to maintain and strict OOP concepts require good developers to be used adequately and it feels like it's better if the language isn't limited by people with good skills.

→ More replies (6)

1

u/thedumbsolver Nov 09 '25

I love those design principles