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. polyga+Ol[view] [source] 2024-01-20 00:11:51
>>XorNot+ri
Immutability is great for multithreaded/async programs because every thread can rest assured knowing no other thread can sneakily modify objects that they are operating on currently.
◧◩◪◨
4. IlliOn+2x[view] [source] 2024-01-20 01:56:59
>>polyga+Ol
How Haskell deals with access to shared resources which are mutable by their nature, like file system, or the outside world?

(A honest question, I start to think that I'd like to learn more on this language)

◧◩◪◨⬒
5. andyfe+kz[view] [source] 2024-01-20 02:22:19
>>IlliOn+2x
AFAIK they tend to operate through the IO monad, which serves to order read/write events and mark parts of your code as interacting with the global mutable state that lives outside your program.

So the mutable (or is it “volatile”?) environment is there, but you explicitly know when and where you interact with it.

[go to top]