43 points · by todsacerdoti · 2y ago · 16 comments
The lack of structured concurrency or anything like thread::scope in async Rust can be quite a headache. Requiring tasks to be 'static basically forces you to Arc<> everything, at which point you start wondering why you aren't just using a GC'd language like Go, Java, or Kotlin.
Recently I read (I can't quite remember where, but I think it was in the context of actors) someone making out computational DAGs as "just a pipeline" - but this misses that a webserver or app or game or whatever should also have DAG-like computation graphs. I might be really on the wrong track here, but trying to jam all these independent "actors" into the one program seems odd - the game players, app users, web clients, etc are other actors. Your database might be an actor. But why would you want your own program to be a bunch of arbitrary actors that can interact with each other willy-nilly? Is there something useful you can do within a single process that isn't possible with structured concurrency?
From the scoped task trilemma:
> Assuming that we are not adding linear types to Rust, ...
Going back to my earlier post, I still wonder if some (theoretical) language with linear types would be able to do structured concurrency with convenient borrows and so-on? (The issues seem related to late drops, leaks, etc).
Is this just tokio thing? For example https://docs.rs/async-executor/latest/async_executor/struct.... does not have 'static in the signature, but I'm not nearly familiar with the topic to understand fully all the details
EDIT: What do you use to make your blog? I quite like the format
Every time I use Rust, my soul wants to see constructions using map, filter, and what not, similar to Scala. But no easy async support for those functions make the resulting code really difficult to look at.