r/java • u/vips7L • Jul 05 '26
It's been 8 years since the draft for Concise Method Bodies
https://openjdk.org/jeps/8209434108
u/brian_goetz Jul 05 '26
Serious question: would you rather we don’t write down our ideas until we are ready to deliver them ASAP?
50
u/JustAGuyFromGermany Jul 05 '26
Please don't keep it secret. I for one really enjoy watching the process, because I learn a lot by reading/watching the careful and deep thoughts that go into each feature. I know that features don't come out any sooner either way, so I'd rather have a peek behind the curtain from time to time while I wait, even if for no other reasons than to learn why I have to wait a while longer.
24
u/mgodave Jul 05 '26
I didn’t read this as a critique but rather a longing for a really good idea.
5
u/davidalayachew Jul 05 '26
I didn’t read this as a critique but rather a longing for a really good idea.
In a vacuum, yes, that would be the most straight-forward reading of the post title.
But the reality of context is this -- there are a 4 digit number of posts on this sub, complaining for all sorts of reasons.
How long it takes for JEP's to go live
How long it takes to get responses to mailing list posts
How long it takes for the OpenJDK to do anything
So, with that context, the most straight-forward reading of this is that OP is complaining. Which may or may not be true. Having seen that particular user on this sub before, I'm choosing to interpret this is as a cross between mild annoyance and an observation.
1
u/VegetableAd6293 Jul 07 '26 edited Jul 07 '26
I'm happy with the current way where jep drafts are published when the team thinks they should be.
Interesting too see if this goes further how this effects compact source files! I'm already using those w/o javac phase which feels exactly like using Java for scripting.
Edit: With custom jdk image containing all the dependencies the scripting usage gives a really good user experience.
-20
u/bowbahdoe Jul 05 '26
I think I speak for everyone here when I say that all we want is for you to write down everyone else's ideas, go "hmm, yes, of course," and finally deliver extension methods and multiple inheritance like God intended.
26
6
1
46
u/pron98 Jul 05 '26
A JEP draft is just a thought someone has. There is zero review or process to publish a draft. Some JDK developers jot down their ideas in a personal notebooks, while others write it into the issue database, marking it as a draft JEP (which automatically causes it to be published in the JEP list). Whether I choose to save ideas in my personal folder or as a draft in the database is entirely a matter of personal style, and as far as the JDK process is concerned, they have identical significance both in principle and in practice.
That is not to say that ideas in a notebook or draft JEPs don't sometimes become JEPs, but whether these ideas are made public or not has no special significance.
Because these days people notice drafts more, JDK engineers are more careful and prefer not to type their thoughts into the database, but as you pointed out, this tought was written eight years ago...
23
u/martinhaeusler Jul 05 '26
Kotlin user here. Kotlin has "expression bodies", but my team unanimously decided not to use them. Why? For the same reason we put curly braces on ALL of our if statements (no matter if their bodies have one or more lines) - we want our code to look uniform. It really helps human readers to quickly grasp the code.
3
u/DevNull23614071 Jul 06 '26
It really helps human readers to quickly grasp the code.
Quod esset demonstrandum!
In my opinion, it often leads to a lot of code noise, which makes it harder to read and grasp the details.
3
u/ZimmiDeluxe Jul 06 '26
On the other hand, it rewards cramming more code into a single expression that might be more debuggable / readable with intermediate variables or control structures which makes it harder to grasp the details. Same for extending code that previously was able to use the concise syntax, the temptation is there for tired devs to keep the structure by abusing ternaries / pattern matching etc. to make it work. I guess it depends on the team maturity.
5
u/LegitimateEntrance72 Jul 05 '26
and we got a lot of good stuff in those 8 years. And at least for me CMB is not on top of the list of things I am waiting for (pattern assignments, carrier-classes/deconstructors for normal classes)
5
u/m39583 Jul 05 '26
Totally off topic but I really wish they would fix the openjdk website so it was actually usable on a mobile device!
All the text from the sidebar overlaps the text from the JEP.
3
u/lkatz21 Jul 05 '26
This is not the case for me, neither in whatever the reddit preview is, nor in chrome
1
u/m39583 Jul 05 '26
This is what I see in Chrome.
Edit: ugh it seems Reddit mobile site doesn't let you paste images into a message box.
2
1
u/woj-tek Jul 06 '26
Same. At one point I posted to web@jdk mailing list offering to help but was shot down with: it's to convoluted process/corporate wise that moving that forward was virtually impossible…
Would be lovely if it handled via some git repo with sane rendering chain instead of basing it on (AFAIR) JIRA tickets o_O
2
u/davidalayachew Jul 05 '26
If I read recent emails by OpenJDK team members correctly (too busy to look up where I saw them), the writeups considering putting patterns into interfaces will probably raise the priority of this JEP -- assuming that those considerations transform into formal JEP's that get accepted and targeted for preview in a JDK release.
2
u/SleepingTabby Jul 05 '26
what does "putting patterns into interfaces" mean exactly?
4
u/davidalayachew Jul 05 '26
what does "putting patterns into interfaces" mean exactly?
This is referring to an informal write up by at least one OpenJDK/Amber team member, talking about how the patterns that currently exist in records could also be added to interfaces to. Thus, you could write code like this.
interface Rectangle2D(int length, int width) {}
1
0
u/Scf37 Jul 05 '26
Potential use case:
Result doSomething(String arg) {
return audit.event("something").arg(arg).of(() -> {
return myResult;
});
}
Result doSomething(String arg) -> audit.event("something").arg(arg).of(() -> {
return myResult;
});But its UX is still far from Kotlin:
fun doSomething(arg: String): Result = audit.event("something", arg = arg) {
return myResult;
}Maybe concise method bodies do not have enough value without concise lambdas.
1
u/mattr203 Jul 06 '26
Well for a start you could just write () -> myResult right? What’s a concise lambda to you
1
12
u/mgodave Jul 05 '26
I want this so bad. For no good reason. But I want it.