zlacker

[return to "The bane of my existence: Supporting both async and sync code in Rust"]
1. xedrac+zh[view] [source] 2024-01-19 23:38:16
>>lukast+(OP)
When writing some IO bound application, async Rust is great. Less great for libraries that want to support both async and sync without having to make an async runtime a dependency if you just want the sync interface. Mutually exclusive features are taboo unfortunately. One thing I really love about Haskell is you can make any function run in a green thread by simply composing it with the 'async' function. There's nothing special about it. This works much better than say Go, because Haskell is immutable.
◧◩
2. anon29+VB[view] [source] 2024-01-20 02:53:51
>>xedrac+zh
> This works much better than say Go, because Haskell is immutable.

The immutability has nothing to do with async. Async is for IO threads. If you want pure parallelism you use `par`. But Haskell IO threads (forkIO and friends) are also green when run with GHC.

◧◩◪
3. xedrac+dG[view] [source] 2024-01-20 03:45:01
>>anon29+VB
Async is definitely nicer when things are immutable. On modern CPUs, async green threads can easily be backed by different OS threads running in parallel on different CPU cores, making data races a real problem for many languages. Async does not guarantee that things will not be run in parallel, although you shouldn't rely on it for explicit parallelism.
◧◩◪◨
4. anon29+NJ1[view] [source] 2024-01-20 15:29:52
>>xedrac+dG
Haskell async is run in IO though in which mutability is allowed. Async itself is mutable.
[go to top]