zlacker

[parent] [thread] 2 comments
1. anon29+(OP)[view] [source] 2024-01-20 02:53:51
> 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.

replies(1): >>xedrac+i4
2. xedrac+i4[view] [source] 2024-01-20 03:45:01
>>anon29+(OP)
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.
replies(1): >>anon29+S71
◧◩
3. anon29+S71[view] [source] [discussion] 2024-01-20 15:29:52
>>xedrac+i4
Haskell async is run in IO though in which mutability is allowed. Async itself is mutable.
[go to top]