Home - Choral Language Website
a choreographic programming language
Install<br>Learn<br>Articles<br>View the source on
Choral is a language for programming choreographies.<br>A choreography is a multiparty protocol that defines how some roles (the proverbial Alice, Bob, etc.) should coordinate with each other to do something together.
You can use Choral to program distributed authentication protocols, cryptographic protocols, business processes, parallel algorithms, or any other protocol for concurrent and distributed systems.<br>At the press of a button, the Choral compiler translates a choreography into a library for each role.<br>Developers can then use your libraries to make sure their programs (e.g. clients and services) follow your choreography correctly—see Choral’s methodology. Choral makes sure that your libraries are compliant implementations of your choreography, makes you more productive, and prevents you from writing incompatible implementations of communications—see Choral’s advantages.
Choral is interoperable with Java and we plan on extending it to support other languages in the future.<br>Choral is compatible with Java in three ways:
its syntax is a direct extension of Java (if you know Java, Choral is just a step away);
you can reuse Java libraries in Choral code;
the libraries generated by Choral are in pure Java with APIs that you control, and can be used inside of Java projects directly.
For now, Choral is a prototype. The language is part of an ongoing research project (see the about page) and future releases might break backwards compatibility. However, Choral is already usable for early adoption and teaching.<br>If you’re curious, you can try it out yourself and get in touch with us!
Hacker News
-->
Explain it like I’m 5!
The problem
Programming distributed systems gives you headaches because you need to figure out how to correctly coordinate multiple programs that interact via side-effects, which you need to manually control (send/receive over channels). If you made some mistakes, finding what went wrong is even harder, because you have to figure out all the possible sequences of communications that can happen (and go wrong) during the concurrent execution of your programs. Testing is hell, as it requires the integration of many distributed components, mocking, etc.
Choral
Choral relieves some of those headaches because you can write as a single program, the whole coordination (protocol) that you want your distributed system to follow.<br>Choral is also friendly to Java programmers (and close to C++, C#, Kotlin, Swift, etc.) because it extends its syntax with a new kind of (higher-kinded) types to let you express things like “the Client communicates this to Service, then Service communicates that to the Login Provider, then […]”. In practice, Choral wraps the headache-mongering side effects used to implement communication within type-safe abstractions, so you can concentrate on the high-level details of the implementation.
If you introduce some incompatibilities between the description of how you want your programs to coordinate and how you actually implemented it, like expecting data at a participant but forgetting to communicate it, the Choral compiler reports you that error and helps you solve it. Moreover, Choral comes with a testing tool (ChoralUnit) that helps you write integration tests with the simplicity of unit tests, performing for you the runtime (integration) tests on your distributed system.
In essence, you program with the simplicity of plain old sequential programs, but you get distributed systems with decentralised control with strong correctness guarantees. This allows you to use or distribute them with a higher level of confidence. You can also reliably compose different Choral(-compiled) programs, to mix different protocol and build the topology that you need.
Language
If you just want to glance at how a Choral program looks like, you can jump to Alice, Bob, and Carol go to a meeting and then come back here for the details.
Choral is an object-oriented language with a twist: Choral objects have types of the form T@(R1, ..., Rn), where T is the<br>interface of the object (as usual), and R1, ..., Rn are the roles that collaboratively implement the object. (Technically, Choral data types are higher-kinded types parameterised on roles, which generalise ideas previosly developed for choreographies and multitier programming; more on that at the end of this page.)
Incorporating roles in data types makes distribution manifest at the type level. For example, we can write a simple program that prints hello messages in parallel at two roles Alice and Bob.
class Hellos@(Alice, Bob) { // A class of objects distributed over two roles, called Alice and Bob<br>public static void main() {<br>System@Alice.out("Hello from Alice"@Alice); // Print "Hello from Alice" at Alice<br>System@Bob.out("Hello from Bob"@Bob); // Print "Hello from Bob" at Bob
Class Hellos is not very interesting,...