Choreographic programming

In computer science, choreographic programming is a programming paradigm where programs are compositions of interactions among multiple concurrent participants.

Choreographies
In choreographic programming, developers use a choreographic programming language to define the intended communication behaviour of concurrent participants. Programs in this paradigm are called choreographies. Choreographic languages are inspired by security protocol notation (also known as "Alice and Bob" notation). The key to these languages is the communication primitive, for example reads " communicates the result of evaluating the expression   to , which stores it in its local variable  ". Alice, Bob, etc. are typically called roles or processes.

The example below shows a choreography for a simplified single sign-on (SSO) protocol based on a Central Authentication Service (CAS) that involves three roles:
 * , which wishes to obtain an access token from  to interact with.
 * , which needs to know from  if the   should be given access.
 * , which is the Central Authentication Service responsible for checking the 's credentials.

The choreography is:

The choreography starts in Line 1, where  communicates a pair consisting of some credentials and the identifier of the service it wishes to access to. stores this pair in its local variable  (for authentication request). In Line 2, the  checks if the request is valid for obtaining an authentication token. If so, it generates a token and communicates a  message containing the token to both   and   (Lines 3–5). Otherwise, the  informs   and   that authentication failed, by sending a   message (Lines 7–8). We refer to this choreography as the "SSO choreography" in the remainder.

Endpoint Projection
A key feature of choreographic programming is the capability of compiling choreographies to distributed implementations. These implementations can be libraries for software that needs to participate in a computer network by following a protocol, or standalone distributed programs.

The translation of a choreography into distributed programs is called endpoint projection (EPP for short).

Endpoint projection returns a program for each role described in the source choreography. For example, given the choreography above, endpoint projection would return three programs: one for, one for  , and one for. They are shown below in pseudocode form, where  and   are primitives for sending and receiving messages to/from other roles.

For each role, its code contains the actions that the role should execute to implement the choreography correctly together with the others.

Development
The paradigm of choreographic programming originates from its titular PhD thesis. The inspiration for the syntax of choreographic programming languages can be traced back to security protocol notation, also known as "Alice and Bob" notation. Choreographic programming has also been heavily influenced by standards for service choreography and interaction diagrams, as well as developments of the theory of process calculi.

Choreographic programming is an active area of research. The paradigm has been used in the study of information flow, parallel computing, cyber-physical systems, runtime adaptation, and system integration.

Languages

 * AIOCJ (website). A choreographic programming language for adaptable systems that produces code in Jolie.
 * Chor (website). A session-typed choreographic programming language that compiles to microservices in Jolie.
 * Choral (website). A higher-order, object-oriented choreographic programming language that compiles to libraries in Java.
 * ChoRus (website). Library-level choreographic programming in Rust.
 * Core Choreographies. A core theoretical model for choreographic programming. A mechanised implementation is available in Coq.
 * HasChor (website). A library for choreographic programming in Haskell.
 * Kalas. A choreographic programming language with a verified compiler to CakeML.
 * Pirouette. A mechanised choreographic programming language theory with higher-order procedures.