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. XorNot+ri[view] [source] 2024-01-19 23:42:57
>>xedrac+zh
I'm not clear what your last sentence has to do with anything else? What does immutability have to do with Async/sync conversions?
◧◩◪
3. throwa+4m[view] [source] 2024-01-20 00:13:36
>>XorNot+ri
you can fearlessly run code on another thread if you're not worried it's going to cause a data race or mutate anything
◧◩◪◨
4. XorNot+Tm[view] [source] 2024-01-20 00:19:44
>>throwa+4m
This is very much not free though. Predicting memory usage in Haskell programs is notoriously tricky (and all the memory copies aren't free either).
◧◩◪◨⬒
5. bippih+Pt[view] [source] 2024-01-20 01:25:55
>>XorNot+Tm
it's not free, but it is explicit. it's nice for the code to explicitly define how the memory is being modified. there are copies in java too, you just have to know how the runtime works to know what each line does.
[go to top]