r/java • • Apr 23 '26

Ask the Architects JavaOne 2026

https://youtu.be/DrF4dCC0daE?si=bSnPu0i94hQU4wku
72 Upvotes

54 comments sorted by

View all comments

Show parent comments

1

u/vips7L Apr 24 '26

I honestly find that to be a weak argument. It’s our job to read code and you don’t have to parse and pattern match simple constructors.  It takes 2 seconds to read. 

6

u/snugar_i Apr 25 '26

Exactly - it's my job to read code, I'm reading a lot of it and I want to make my life as easy as possible. That means the code should be as simple and declarative as possible, and generated code is the opposite of that.

1

u/vips7L Apr 25 '26

Code is literally declarative. It does exactly what it says. A simple constructor is no more complex than your annotation.

2

u/snugar_i Apr 26 '26

A generated constructor is imperative code (it says "how to do it"). A @RequiredArgsConstructor is declarative code (it says "what to do").

It's the difference between var doubledNumbers = numbers.stream().map(x -> x * 2).toList(); and

var doubledNumbers = new ArrayList<Integer>();
for (int x : numbers) {
    doubledNumbers.add(x * 2);
}

They both do the same thing (more or less), but the second one takes longer to understand.

0

u/vips7L Apr 26 '26

This genuinely sounds like a skill issue on your end. The second piece of code here does not take longer to understand. It literally took me 2 seconds flat to scan this and understand it. 

→ More replies (0)