First published at 23:26 UTC on July 14th, 2018.
What would be a good domain-specific language (DSL) for expressing concurrent and parallel computations in a natural and declarative manner?
The goal is to design a programming language where the programmer can simply say "this computation wit…
MORE
What would be a good domain-specific language (DSL) for expressing concurrent and parallel computations in a natural and declarative manner?
The goal is to design a programming language where the programmer can simply say "this computation with this data here needs to be made concurrent" - and obtain automatically parallelized, concurrent code, safe from race conditions.
Starting from examples and proceeding systematically, I derive precisely such a DSL for concurrent programming.
I show that, in order to achieve this kind of high-level, purely declarative concurrency, a programming language needs just two features:
1. A construction that labels data values as "concurrent data", using locally scoped "labels" (which are values of a special type).
2. A construction to define "concurrent functions" that can take labeled "concurrent data" as input and will emit new "concurrent data" as output.
The need for these two features is a logical consequence of our requirement to be able to denote concurrency declaratively, and to achieve automatic yet safe parallelism.
A programming language with these two features is equivalent to the "Chemical Machine", also known as "join calculus" in the academic literature. I demonstrate working test code in Scala using the Chemical Machine via the `Chymyst` library.
I explain how the "chemical metaphor" provides a more visual terminology that helps us understand how "concurrent data" and "concurrent functions" actually work.
Code for the presentation: https://github.com/Chymyst/Chymyst/blob/master/src/test/scala/io/chymyst/lab/ChymystPresentation.scala
Main repository for the `Chymyst` library: https://github.com/Chymyst/chymyst-core/
"Concurrency in Reactions", a tutorial book on Chymyst and Chemical Machine programming: https://winitzki.gitbooks.io/concurrency-in-reactions-declarative-multicore-in/content/
LESS