Functional programming and concurrency
The most effective concurrent processing occurs where there are no dependencies among the tasks being performed. The biggest difficulty in developing concurrent (or parallel) programming is coordinating updates to shared resources.
When following functional design patterns, we tend to avoid stateful programs. A functional design should minimize or eliminate concurrent updates to shared objects. If we can design software where lazy, non-strict evaluation is central, we can also design software where concurrent evaluation is helpful. This can lead to embarrassingly parallel design, where most of the work can be done concurrently with few or no interactions among computations.
Dependencies among operations are central to programming. In the 2*(3+a)
expression, the (3+a)
subexpression must be evaluated first. The overall value of the expression depends on the proper ordering of the two operations.
When working with a collection, we often have situations where...