3 ms·
Personally I love explicit coroutines for their flexibility. It's great to be able to multiplex a bunch of IO bound operations on a single thread, defining some
by mplanchard 3y ago
Personally I love explicit coroutines for their flexibility. It's great to be able to multiplex a bunch of IO bound operations on a single thread, defining some in chains and other to execute in parallel. It's great to be able to easily decide when I want to wait for them all to finish, to do something like `select`, or to spin them off into the background. Rust's ownership occasionally makes this a bit more of a challenge than I would like it to be, but I certainly wouldn't trade the ability for a more "convenient" syntax.
- rkangel 3y agoElixir and its Task module (https://hexdocs.pm/elixir/1.12/Task.html https://hexdocs.pm/elixir/1.12/Task.html) is the best of both worlds here. The fundamental concurrency system is green threads (similar to Go), which makes for a fantastic programming model where you spend your time writing linear blocking code, while actually having full parallelism. This is achieved both with the VM and the abstractions built on top like GenServers. The Task module is a convenience that allows you to do "await" type work when that makes sense - because (as you describe) sometimes it does.