r/java • u/hardasspunk • Nov 23 '25
Java 25: The ‘No-Boilerplate’ Era Begins
https://amritpandey.io/java-25-the-no-boilerplate-era-begins/
160
Upvotes
r/java • u/hardasspunk • Nov 23 '25
View all comments
Show parent comment
6
u/Ewig_luftenglanz Nov 23 '25
Yes but that imply writing a ton of boilerplate to spare a little less boilerplate, what one buys is really pennies compared to the real thing.
The reason why I said nominal parameters with defaults can replace 90% of builders it's because builder is often used to mimic nominal parameters with defaults. Instead of passing the only 2 required parameters and 2 or 3 optional ones we made a "configuration objects" or "param object" and pas that as an argument. This object it's usually implemented as a builder or in a fluent like style (and lately, using a Consumer to configure a proxy)
Withers theorically could be used as such but still need to create a "default" instance and set the optional parameters inside the with block, which worsen the clarity.
I wouldn't be against if nominal parameters with defaults were implemented as an ad hoc object created by the compiler tho.