97 Things Every Programmer Should Know

(Chris Devlin) #1

Collective Wisdom from the Experts 115


processes are a very successful mechanism for programming concurrent and
parallel systems. Such systems do not have all the synchronization stresses
that shared-memory, multithreaded systems have. Moreover, there is a formal
model—Communicating Sequential Processes (CSP)—that can be applied as
part of the engineering of such systems.


We can go further and introduce dataflow systems as a way of computing. In
a dataflow system, there is no explicitly programmed control flow. Instead, a
directed graph of operators, connected by data paths, is set up and then data
is fed into the system. Evaluation is controlled by the readiness of data within
the system. Definitely no synchronization problems.


That said, languages such as C, C++, Java, Python, and Groovy are the prin-
cipal languages of systems development, and all of these are presented to
programmers as languages for developing shared-memory, multithreaded
systems. So what can be done? The answer is to use—or, if they don’t exist,
create—libraries and frameworks that provide process models and message
passing, avoiding all use of shared mutable memory.


All in all, not programming with shared memory, but instead using message
passing, is likely to be the most successful way of implementing systems that
harness the parallelism that is now endemic in computer hardware. Perhaps
bizarrely, although processes predate threads as a unit of concurrency, the
future seems to be in using threads to implement processes.

Free download pdf