3 ms·
I'm curious to see how structured concurrency feels in production. I'm still leaning towards C#'s async and TPL syntax. Manual context, fork and unwrap syntax
by jayd16 3y ago
I'm curious to see how structured concurrency feels in production. I'm still leaning towards C#'s async and TPL syntax. Manual context, fork and unwrap syntax might feel cumbersome. I enjoy the await sugar and implicit context handling but the explicit scopes solves the bugs you see in C# where the default thread pool is abused.
- pjmlp 3y agoDavid Fowler has tweeter threads about researching how Java and Go do it, including an experimental runtime. By the way, .NET already has structured concurrency via Dataflow.
- vips7L 3y agoGreen Threads Experiment if anyone is interested in what they've done in .NET: https://github.com/dotnet/runtimelab/issues/2057 https://github.com/dotnet/runtimelab/issues/2057 Personally Asyc/Await is the only thing keeping me from the C# ecosystem.
- jayd16 3y agoA bit ironic that the last post is a UI thread question. I would welcome green threads or a virtual threading system, but considering the UI work that C# handles, its no wonder async/await was implemented. If Java virtual threads are a success, I expect C# to follow suit.
- vips7L 3y agoIt seems appropriate that C# would include both models. The language design seems to allow you to choose what tool is best for your application.
- pjmlp 3y agoIt won't, this was discussed at BUILD 2023, and they have no plans to do so as they would need to duplicate the API surface of many low level capabilities. If I am not mistaken it was on this session, "ASP.NET Core and Blazor futures, Q&A" https://build.microsoft.com/en-US/sessions/4cfe374e-a9a0-4a82-a9b6-890bd90df931?source=/favorites https://build.microsoft.com/en-US/sessions/4cfe374e-a9a0-4a8...
- pjmlp 3y agoIt won't, this was discussed at BUILD 2023, and they have no plans to do so. If I am not mistaken it was on this session, "ASP.NET Core and Blazor futures, Q&A" https://build.microsoft.com/en-US/sessions/4cfe374e-a9a0-4a82-a9b6-890bd90df931?source=/favorites https://build.microsoft.com/en-US/sessions/4cfe374e-a9a0-4a8...
- unscaled 3y agoWhile virtual threads will be stable in Java 21, Structured Concurrency is still a preview feature. You probably won't see it in production anytime soon. Preview features require a special flag when compiling and running them, and they won't run on newer versions of the JVM. I don't expect to see StructuredTaskScope in common production use before the next LTS version is out. But it doesn't mean you cannot have structured concurrency before that. Even in language that mostly enforce Structured Concurrency like Kotlin, it's still a library feature. Even the original blog post which formulated this concept, described a library that implemented structured concurrency for Python[1]. You can pretty easily implement structured concurrency yourself by creating your own implementation of StructuredTaskScope, if you need it right now. You can even structured concurrency in C#[2] or Go[3]. [1] https://vorpus.org/blog/notes-on-structured-concurrency-or-go-statement-considered-harmful/ https://vorpus.org/blog/notes-on-structured-concurrency-or-g... [2] https://github.com/StephenCleary/StructuredConcurrency https://github.com/StephenCleary/StructuredConcurrency [3] https://github.com/sourcegraph/conc https://github.com/sourcegraph/conc