5 ms·
Yes. Functional languages are amenable to composition. Because of their "purity". This allows trivial extraction of parallelism/concurrency. No need to reason a
by yshalabi 12y ago
Yes. Functional languages are amenable to composition. Because of their "purity". This allows trivial extraction of parallelism/concurrency. No need to reason about interleaving and shared data and such.
But, I don't know if "use FP if you want parallelism" is an acceptable solution currently. My intuition is that latency sensitive application can't use these languages because they don't expose the low-level primitives (read pointers) that make the difference in such applications. But I haven't written and profiled enough FP code to know if this is absolutely the case.
- zaphar 12y agoNo, Functional languages reduce the problems surface area but they don't eliminate it. You can still get data races and deadlocks in Haskell. They aren't the same as a memory race in say C where the contents of a variable might change out from under you in truly bizarre ways but you still get algorithmic races where the wrong answer comes our the other end because two parallel operations happened in the wrong order.
- rthomas6 12y ago>two parallel operations happened in the wrong order. I thought separate functions weren't allowed to have dependencies like this?
- taeric 12y agoSimply put, not everything is commutative.
- marcosdumay 12y agoYou can't get deadlocks and data races on pure code. Once your code is in a monad, every one of those problems may be back (including memory race).
- elihu 12y agoThe IO monad in particular. Monads by themselves don't introduce races/deadlocks.
- codygman 12y agoIn regards to pointers and pure functional languages: https://ghc.haskell.org/trac/ghc/wiki/StaticPointers https://ghc.haskell.org/trac/ghc/wiki/StaticPointers