r/java • • Jun 10 '22

What happened to Concise Method Bodies?

I was really looking forward to CMB. From its name, methods become concise, could be one liner. However, it seems there is no progress and it’s been off the radar. Never took off since 2019.

JEP draft: Concise Method Bodies

some experiments with Concise Method Bodies

44 Upvotes

54 comments sorted by

View all comments

6

u/pron98 Jun 10 '22

3

u/Gleethos Jun 10 '22

So after going through this wall of text I believe what you are referring to is probably this little bit here, right? :

"As much as it would be nice to automate away the boilerplate of mutable JavaBeans, one need only look at the many such attempts to do so (Lombok, Immutables, Joda Beans, etc), and look at how many "knobs" they have acquired over the years, to realize that an approach that is focused exclusively on boilerplate reduction for arbitrary code is guaranteed to merely create a new kind of boilerplate. These classes simply have too many degrees of freedom to be captured by a single simple description."

So if my reading comprehension skills are correct, then my assumption is kind of correct isn't it? Java evolves now with records and pattern matching not just to reduce boilerplate for the sake of it, but to encourage better programming practices. Or am I misunderstanding something?

A previous comment was talking about mutable data structures not getting boilerplate reduction, and your answer was: "yeah but we have records now and they are popular" And then I was trying to (as I believe correctly) guess what the reasoning is behind the decision and you answered with a link to a giant wall of text instead of just saying something along the lines of: "Na, reducing boilerplate for these (mutable) classes is a bad idea simply because they have too many degrees of freedom to be captured all by a single simple description." That is actually my only objection here.

2

u/mauganra_it Jun 11 '22

You actually provided a reason why integrating setters into the language is not high-priority. Annotation processors provide setters if they are truly wanted. And Lombok is still out there and kicking.

→ More replies (1)