ArticleslgStudy

computer science

Choreographic programming

Choreographic programming is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Choreographic programming rather than just read about it. In short: In computer science, choreographic programming is a programming paradigm for distributed systems, where programs are written as compositions of interactions among multiple concurrent participants. Deadlock is a common error that can occur in distributed systems.

Key takeaways

  • Choreographic programming belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Choreographic programming to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Choreographic programming from memory before moving on to harder problems.

Reference excerpt

In computer science, choreographic programming is a programming paradigm for distributed systems, where programs are written as compositions of interactions among multiple concurrent participants. Deadlock is a common error that can occur in distributed systems. Choreographic programming ensures that deadlock cannot occur in the scope of the choreography by ensuring that every time a message is sent from one party, there is a corresponding receive on the other end.

Overview

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 "Alice communicates the result of evaluating the expression expr to Bob, which stores it in its local variable x". 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:

Client, which wishes to obtain an access token from CAS to interact with Service. Service, which needs to know from CAS if the Client should be given access. CAS, which is the Central Authentication Service responsible for checking the Client's credentials. The choreography is:

The choreography starts in Line 1, where Client communicates a pair consisting of some credentials and the identifier of the service it wishes to access to CAS. CAS stores this pair in its local variable authRequest (for authentication request). In Line 2, the CAS checks if the request is valid for obtaining an authentication token. If so, it generates a token and communicates a Success message containing the token to both Client and Service (Lines 3–5). Otherwise, the CAS informs Client and Service that authentication failed, by sending a Failure 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 Client, one for Service, and one for CAS. They are shown below in pseudocode form, where send and recv 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. A session-typed choreographic programming language that compiled to microservices in Jolie. In the meantime superseded by Choral. Choral (website). An object-oriented choreographic programming language that compiles to libraries in Java. Choral is the first choreographic programming language with decentralised data structures and higher-order parameters. Chorex (website). An Elixir library providing an embedded choreographic programming language through Elixir's macro system. ChoRus (website). Library-level choreographic programming in Rust. Core Choreographies. A core theoretical model for choreographic programming. A mechanised implementation is available in Rocq. 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. Klor (website). Library-level choreographic programming in Clojure. Tempo (website). A practical choreographic programming language that compiles to library source code for multiple target languages. Wyzer (website). A statically-typed, general-purpose, resource-oriented choreographic programming language that compiles to native code via LLVM, using a Perceus-based memory model for automatic memory management alongside its choreography features.

See also Security protocol notation Sequence diagram Service choreography Structured concurrency Multitier programming

References

External links www.choral-lang.org

Worked examples

Example 1 — a first encounter with Choreographic programming

Start with the simplest possible case. Write down what Choreographic programming claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Choreographic programming before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Choreographic programming ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Choreographic programming

In research
Choreographic programming appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Choreographic programming in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Choreographic programming is common in secondary-school and first-year university syllabi. It links to neighbouring topics Concurrent computing, Programming paradigms, so understanding it makes those chapters shorter.
In everyday life
Look for Choreographic programming outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Choreographic programming” →

How to study Choreographic programming in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Choreographic programming means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Choreographic programming out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Choreographic programming in simple terms?

In computer science, choreographic programming is a programming paradigm for distributed systems, where programs are written as compositions of interactions among multiple concurrent participants. Deadlock is a common error that can occur in distributed systems.

Why does Choreographic programming matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Choreographic programming?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Choreographic programming.

Tags

  • Concurrent computing
  • Programming paradigms

Keep exploring