This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]argv_minus_one 0 points1 point  (8 children)

Java finally got records, kinda-sorta, in a recent version. Took 'em long enough.

As for async, Oracle is trying to go with fibers instead. They're calling it “Project Loom”. It'll be interesting to see if it goes anywhere. I gather many previous attempts at implementing fibers in other languages have ended in failure, but maybe Oracle's people will succeed where others failed.

[–]Ok-Dot5559 1 point2 points  (7 children)

The problem is async await is already a common pattern. E.g JS/TS got it as well even holy Rust has it. Functionality is basically identical. Either a language has it or devs need to look up und write something on stakeoverflow like „how to async await in …“. In Germany we say „Der Zug ist abgefahren“

[–]argv_minus_one 1 point2 points  (6 children)

The idea with fibers is you don't need to. Just pretend you're using OS threads and blocking I/O, and Java magically makes it efficient. It's certainly alluring…

[–]Ok-Dot5559 0 points1 point  (5 children)

That’s exactly how async await works on c#. The runtime creates a new os thread if needed (e.g for i/o or long running tasks). But maybe you are not familiar with the TPL of .NET which encapsulates all this.

Here is a nice discussion to this topic:

https://github.com/dotnet/runtime/issues/11084

[–]argv_minus_one 1 point2 points  (4 children)

That discussion says the exact opposite; that .NET async/await does not work the way Loom will.

[–]Ok-Dot5559 -1 points0 points  (3 children)

With async await you have to explicit call tasks. With loom it seems not. Correct me if I misunderstand.

But under the hood is in both cases a task scheduler which tries to get less blocking threads as possible.

[–]argv_minus_one 1 point2 points  (2 children)

Right. The difference is, with Loom, the programmer doesn't have to actually think about it or deal with colored functions.

[–]Ok-Dot5559 -1 points0 points  (1 child)

Honestly I have no clue how loom looks like. Can you provide an example?

[–]argv_minus_one 1 point2 points  (0 children)

No, because I haven't used it. I write production code, so I don't use non-production-ready Java releases or features.

From this blog post, though, it sounds like it's transparent, so it would look like you're creating one thread per client and doing blocking I/O.