<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<font size="4"><font face="monospace">Hi Tom;<br>
<br>
This isn't really the right forum for this, but I can provide
some quick answers. <br>
<br>
First, let me speak to the claim that Java hasn't taken the
approach of "adopting features from other languages". I think
this claim is problematic in a number of dimensions. <br>
<br>
There is really no such thing as "adopting a feature from
another language" in the first place; every feature interacts
with other features in the language, and so even if one wants to
have a feature "as much like X from language Y as possible", it
still must be the subject of a clean-sheet design -- otherwise
it will look bolted on the side (because it will have been.)
Think of it as an organ transplant; the hard part is
reconnecting all the small connections. <br>
<br>
So rather than think about adopting _features_, it is instead
more profitable to _draw inspiration_ from things we observe in
other environments. And very often, the inspiration comes not
from a specific feature in language X, but from the places that
X drew its inspiration from. (Sometimes this chain can be
followed for several hops.) <br>
<br>
I don't quite know where you would get the idea that Java
doesn't draw inspiration from elsewhere; I can assure you that
we have drawn extensive inspiration from other languages and
from the larger PL literature base -- as I would expect most
other languages to do. But we are also mindful that not every
feature in every language is worthy of being emulated. <br>
<br>
To your concrete points, both of these features were extensively
considered -- and explicitly rejected as poor ideas for Java.
During Project Lambda, the weaknesses of extension methods were
extensively discussed. During Project Loom, the weaknesses of
async/await were similarly discussed at length. That Java
doesn't have this feature is not because we're unaware of them,
or because we're afraid of copying them -- they're just not good
enough ideas. <br>
<br>
Sometimes programming languages do things that are superficially
interesting, but turn out to be bad ideas. Java has learned
from the experiences of other languages with respect to these
two particular ideas, and what we learned was that these
features cause at least as many problems as they solve. <br>
<br>
<br>
</font></font><br>
<div class="moz-cite-prefix">On 6/10/2023 1:46 AM, Tom Rosenfeld
wrote:<br>
</div>
<blockquote type="cite" cite="mid:CA+rpbhQmuwB9F7d2-jLgNXmTp3GCNL0pYCNdN=UDRT=Ewiwqdg@mail.gmail.com">
<div dir="ltr">
<div class="gmail-flex gmail-flex-grow gmail-flex-col
gmail-gap-3">
<div class="gmail-min-h-[20px] gmail-flex gmail-flex-col
gmail-items-start gmail-gap-4 gmail-whitespace-pre-wrap
gmail-break-words">
<div class="gmail-markdown gmail-prose gmail-w-full
gmail-break-words gmail-dark:prose-invert gmail-light">
<p>Hello Everyone,</p>
<p>I hope this is an appropriate forum for the thoughts
I'd like to share on Java. If not, I would appreciate
guidance as to the most fitting venue for such a
discussion.</p>
<p>Currently, I am contemplating two main points related
to programming languages, specifically in relation to
Java. First, it seems that many languages frequently
adopt features from each other, and I'm curious as to
why Java hasn't taken a similar approach.</p>
<p>In particular, I've been considering the potential
benefits of integrating extension methods and
async-await into Java. With extension methods, users
could benefit from a more concise syntax and a more
functionally expressive coding approach. The async-await
feature, a staple in languages like C# or JavaScript,
might even be a superior alternative to Structured
Concurrency. For instance, consider the code in this
post: <a href="https://www.infoq.com/news/2023/06/structured-concurrency-jdk-21/" moz-do-not-send="true" class="moz-txt-link-freetext">https://www.infoq.com/news/2023/06/structured-concurrency-jdk-21/</a></p>
<p>In C#, it might look something like this:</p>
public async Task<Response> HandleAsync() {<br>
Task<string> userTask = FindUserAsync();<br>
Task<int> orderTask = FetchOrderAsync();<br>
await Task.WhenAll(userTask, orderTask);<br>
return new Response(userTask.Result, orderTask.Result);<br>
}
<p>In comparison to the original, this version seems
considerably shorter, clearer, and easier to read.</p>
<p>I look forward to hearing your thoughts on this matter.</p>
<p>Best,</p>
<p>Tom</p>
</div>
</div>
</div>
</div>
</blockquote>
<br>
</body>
</html>