3 ms·
Yes. Concurrency is easier in functional languages. Many of them provide a concurrency monad which allows you to write expressions like this: read_from_soc
by toolslive 7y ago
Yes. Concurrency is easier in functional languages.
Many of them provide a concurrency monad which allows you to write expressions like this:
read_from_socket_into_buffer params >>=
process_buffer >>=
...
Where you roughly read the '>>=' as follows: "the left side might take an arbitrary amount of time to produce a result. While it's off and doing its thing, go and do something else. Once it has produced the result, take it and feed it as a parameter to function on the right."
BTW, It's quite easy to implement your own concurrency monad, however: the real work is the wrapping of all the blocking system calls into this framework.
- zelphirkalt 7y agoThis sounds a bit like async in some other languages.
- dahfizz 7y agoLots of functional language featured end up copied into traditional languages (monads, immutability, pattern matching, lambdas, etc). The difference is that these are almost always more ergonomic in a functional language that was designed with these features in mind vs. having them bolted on afterwards