It's maybe interesting to note that the `async` library in use here is very simple and easy to understand. Nearly every function is one or two lines. Likewise `TQueue` is extremely simple (and easy to prove correct) thanks to STM, and also generally has good performance.
Concurrency in Haskell: Fast, Simple, Correct
31–40 of 129 posts
Re: Concurrency in Haskell: Fast, Simple, Correct
#32In another life I will be a Haskell programmer
Re: Concurrency in Haskell: Fast, Simple, Correct
#33I’m not familiar with Haskell concurrency. The combination of green threads and large memory allocations due to immutable data structures sounds like it would be hard to implement a web server handling 10k+ concurrent requests on commodity hardware? Btw. too bad author talks about microsecond guarantees usage but does not provide a link, that would be interesting reading.
Re: Concurrency in Haskell: Fast, Simple, Correct
#34Re: Concurrency in Haskell: Fast, Simple, Correct
#35Rust has a bunch of these while being maintainable.
What is Rust's feature for safe shared&mutable state?
Re: Concurrency in Haskell: Fast, Simple, Correct
#36It's maybe interesting to note that the `async` library in use here is very simple and easy to understand. Nearly every function is one or two lines. Likewise `TQueue` is extremely simple (and easy to prove correct) thanks to STM, and also generally has good performance.
Re: Concurrency in Haskell: Fast, Simple, Correct
#37In another life I will be a Haskell programmer
Re: Concurrency in Haskell: Fast, Simple, Correct
#38I love Haskell because I can write provably correct code that still doesn’t work
I love it because I can spend all my time noodling over types and never ship a product that would have been great shipped in a late night wine-fueled session of 1999 PHP.
Re: Concurrency in Haskell: Fast, Simple, Correct
#39Earlier quoted context omitted.
You are correct, Haskell has quite a few mutex-like types. MVar is one of them. However, if memory serves me right, TVar is a building block for the transactional memory subsystem. The guard on TVar with, say, modifyTVar is not really stopping execution at entrance but simply indicating that the block modifies the variable. In my mental model, some magic happens in an STM block that checks if two concurrent STM block…
https://zio.dev/reference/stm/
Does Zio actually offer any protection here, or is it just telling the reader that they're on their own and should be wary of footguns?
Re: Concurrency in Haskell: Fast, Simple, Correct
#40I thought it was a bit odd that the author claims there’s no mutexes in sight, the TVar is effectively a mutex guard unless I’m misunderstanding this? (I’ve written exactly 0 lines of Haskel). Or is the claim that the lack of ceremony and accidental complexity around threading is the real win for concurrency here?
If you lock a section of code (to protect data), there's no guarantee against mutations of that data from other sections of code.
If you lock the data itself, you can freely pass it around and anyone can operate on it concurrently (and reason about it as if it were single-threaded).
It's the same approach as a transactional database, where you share one gigantic bucket of mutable state with many callers, yet no-one has to put acquire/release/synchronise into their SQL statements.