Hacker News new | ask | show | jobs
by didibus 224 days ago
> No hidden control flow.

I've really been thinking about this one.

I'm currently designing and implementing an async library and I've been wondering what's better, structured concurrency or explicit scopes.

Explicit scopes allow you to see and think exactly how you want to relate every async task or not. But you have to pass it around, it's more verbose, and you can get mixed up in your scopes.

Structured concurrency handles it automatically, the structure of the code is implicitly the scope of your tasks. Less verbose, can't forget about it, or get it mixed up, but it's magical, you might not even realize it's happening, and understanding mentally what the scope ends up being requires you to understand really well how the structured concurrency implicitly infers your scopes.

I can't decide which is best.

2 comments

Consider the explicit solution and a layer of sugar for making it implicit from structure, whether it's macros or a DSL or whatever. Abstractions work best when they stack.
Zig or Rust?
Actually Clojure :p

I'm just looking for inspiration elsewhere and I see Zig and Rust as each having chosen the opposite path.

Zig is explicit, pass everything around, the allocator, scopes, etc.

Rust is implicit and heavily structured, allocation, lifetime, scopes is all based on code structure.