Hacker News new | ask | show | jobs
by jayd16 700 days ago
It's foolish to say that green threads are strictly better and ignore async/await as something outdated. It can do a lot that green threads can't.

For example, you can actually share a thread with another runtime.

Cooperative threading allows for implicit critical sections that can be cumbersome in preemptive threading.

Async/await and virtual threads are solving different problems.

> What is perhaps worse is that C# lacks an interruption model

Btw, You'd just use OS threads if you really needed pre-emptively scheduled threads. Async tasks run on top of OS threads so you get both co-opertive scheduling within threads and pre-emptive scheduling of threads onto cores.

1 comments

> It's foolish to say that green threads are strictly better and ignore async/await as something outdated

I’m not sure I said outdated, but I can see what you mean by how I called Javas approach “more modern”. What I should have called Javas approach was “correctly designed”.

C#’s async/await isn’t all terrible as you point out, but it’s designed wrong from the bottom up because computation should always be blocking by default. The fact that you can accidentally start running your code asynchronous is just… Aside from trapping developers with simple mistakes, it’s also part of what has lead to the ecosystem irrecoverably being split into two.

I was actually a little surprised to see Microsoft make their whole .Net to .Net core without addressing some of the glaring issues with it, when that massive disruption process uprooted everything anyway.

What do you think about the Structured Concurrency library Java is working with things like fork() and join()? Is that incorrectly designed? Why do you think there's a call for that if virtual threads serves every use case?