Friday, August 24, 2007

Implicit vs. Explicit Parallelism in COSA and Erlang

Even though Erlang is officially defined as a concurrent programming language, parallel processes in an Erlang program must be explicitly created or spawned whereas sequential operations are implicit. That is to say, no special keywords or primitives are needed to specify that certain operations must occur in a specific order but this is not the case for parallel processes. In Part 1 of Concurrent Programming in Erlang we read:
Sequential Erlang needs the addition of a small number of primitives to turn it into a concurrent programming language. We introduce the primitives necessary to create a parallel process and for message passing between processes.
In COSA, by contrast, parallelism is implicit and sequential operations must be explicitly specified. What this means is that, if two operations must be executed in a particular order, the programmer must explicitly specify the order. This is done simply by drawing a line between the two cells that represent the operations.




The figure above shows a COSA component or module that contains a number of elementary operations or cells (blue and yellow circles). COSA modules are automatically assumed to be concurrent. There is no need for the program designer to specify this. Cells are the only processes in COSA and, unlike Erlang processes, which have arbitrary durations, every COSA cell executes its operation in exactly one system cycle. This is done in order to enforce the deterministic timing of operations, an absolute must for reliability. A small red circle represents the output of a cell. Every cell emits an output signal as soon as it is done executing. The application designer must explicitly connect the output of one cell to the input of another cell in order to specify the order of execution. The benefit of this approach is that, unlike Erlang's algorithmic processes, a COSA sequence can easily fork into two or more other sequences. Forks should be used as much as possible because they automatically take advantage of the parallel processing capabilities of the hardware, if any. This is the main difference between algorithmic and non-algorithmic sequences. Cells are explained in greater detail on the COSA system page.


The point that I am driving at is that, in a truly concurrent development environment, parallelism must be implicit and sequential ordering explicit. Not the other way around. This approach facilitates good program comprehension and it is one of the things that differentiate COSA from concurrent programming languages like Erlang. Implicit parallelism in a graphical programming environment is part of the future of parallel software construction, in my opinion. Computer languages are ill-suited to parallel programming because they are inherently sequential. Lately, I have fallen in love with Jeff Han's amazing multi-touch interface technology. It think it is perfectly suited for parallel application development.

No comments: