Hacker News new | ask | show | jobs
by jacques_chester 1909 days ago
I am unreasonably excited by Loom, for two reasons:

1. I cannot wrap my head around library-based reactive systems. I have tried and tried and continue to try. But they're like some of the original Go4 design patterns: they exist to solve the language, not the problem. Loom's promise to make steam-powered linear code behave mostly like a fully-dressed reactive library system is extremely welcome.

2. Structured concurrency. Among the entries on the thick tablet of hatreds of Golang that I carry upon my heart, mystery action at a distance due to go(to) routines appears infrequently but painfully. Like so many Go features they conspire against composability and testability. Structured concurrency looks like an escape from the madness. Please let it be true.

4 comments

What you're waiting for is already available with Kotlin coroutines (which has a very clean API btw) And no reactive streams still are useful for processing collection streams asynchronously and here again kotlin solve it all https://kotlinlang.org/docs/flow.html
I like Kotlin coroutines and I've used them, but they (this argument is controversial) have a function colouring problem. As the JVM adds virtual threads I expect that a rebasing of Kotlin's coroutines will remove that objection.

Plus, sometimes, I want to use Java.

Also debugging with them can be quite painful. It is getting better, but I still pull my hair frequently.
Agreed !

Current reactive code is littered with async/await for every IO function, which feels like they are trying to bolt reactive behavior. Library-based threading model provide the sync thinking with optimized async compute model.

What's the difference in programming model (not implementation) between Loom and goroutines?
Not exactly. That's the programming rule for structured concurrency which is a very simple bit of logic added on to the ExecutorService class. Loom itself is just about making threads super cheap/fast. You can use new cheap threads in exactly the same way as normal and nothing will complain. You can also use structured concurrency with old threads, and again, nothing will complain. And you don't need Java support for structured concurrency. You could implement it today with some wrapper classes.
No, not exactly. Thus ever the fate of tl;drs.

The discussion further down about "scope variables" foreshadows making structured concurrency more strongly, directly supported by the language's runtime:

> What about inheritance? Because SVs are immutable, and because structured concurrency also gives us a syntax-confined thread lifetime, SV inheritance fits structured concurrency like a glove

Scoped vars are nice but I never saw anyone claim they're a required part of structured concurrency. They're mostly an optimisation over ThreadLocal.
I never said required.
What do you mean by structured concurrency? Do you mean hierarchy management?
Sort of. Here is the original proposal often referred to by Loom's architects:

https://250bpm.com/blog:71/

Here is what the wiki has to say:

https://wiki.openjdk.java.net/display/loom/Structured+Concur...