Real-World Choreographic Programming: An Experience Report
Choreographic programming is a programming paradigm, whereby the overall behaviour of a distributed system is coded as a choreography from a global viewpoint. The choreography can then be automatically compiled (projected) to a correct implementation for each participant. Choreographic programming relieves the programmer from manually writing the separate send and receive actions performed by participants and avoids the problem of communication mismatches. However, the applicability of this paradigm in the real world remains largely unexplored for two reasons. First, while there have been several proposals of choreographic programming languages, none of them have been used to implement a realistic, widely-used protocol. Thus there is a lack of experience on how realistic choreographic programs are structured and on the relevance of the features explored in theoretical models. Second, applications of choreographic programming shown so far are intrusive since each participant must use exactly the code projected from the choreography. This prevents using the projected code with existing third-party implementations of some participants. We carry out the first development in choreographic programming of a widespread real-world protocol: the Internet Relay Chat (IRC) protocol. Our development is based on Choral, an object-oriented choreographic programming language. Two of Choral's features are key to our implementation: higher-order choreographies for modelling the complex interaction patterns due to IRC's asynchronous nature; and user-definable communication semantics for achieving interoperability with third-party implementations. We also discover a missing piece: the capability of statically detecting that choices on alternative distributed behaviours are appropriately communicated by means of message types. We extend the Choral compiler with an elegant solution based on subtyping.
READ FULL TEXT