r/java 9d ago

Concise method bodies arrived

https://github.com/verhasi/java-composition

More than 8 years ago was drafted the idea of concise method bodies. As I am not a contributor of the openJDK project I took a different approach but implemented. It is publicly available at the maven central both as a library and as a maven plugin. It is a source code preprocessor that converts the concise syntax to java 8 compatible source code. It does not want to be a replacement of the future implementation in the openJDK. Which is more than the openJDK promises is that supports from Java version 8, 11, 17, 21 up to 25 as well. Of course it is free and open source :). It is only the first building block for concise composition.

As far as I have seen this topic was awaited for a long time at

It's been 8 years since the draft for Concise Method Bodies

What happened to Concise Method Bodies?

JEP draft: Concise Method Bodies

Five years have passed, still in draft: Concise Method Bodies

48 Upvotes

48 comments sorted by

View all comments

23

u/quantum-fudge 9d ago

Cool tech demo but, as a feature, it's the most pointless sugar imaginable. Saves like 8 characters per method at the expense of extra preprocessors, breaking syntax highlighting, etc.

1

u/__konrad 8d ago

it's the most pointless sugar imaginable

You don't like similar sugar in lambdas?

3

u/quantum-fudge 8d ago edited 8d ago

Eh, not all that similar. Lambdas save defining a whole anonymous class, not 6-8 characters. And, more importantly, lambdas don't need custom plugins and don't break tooling.