Choreographic programming (CP) is a paradigm for implementing distributed systems that uses a single global program to define the actions and interactions of all participants. Library-level CP implementations, like HasChor, integrate well with mainstream programming languages but have several limitations: Their conditionals require extra communication; they require specific host-language features (e.g., monads); and they lack support for programming patterns that are essential for implementing realistic distributed applications. We make three contributions to library-level CP to specifically address these challenges. First, we propose and formalize conclaves and multiply-located values, which enable efficient conditionals in library-level CP without redundant communication. Second, we propose end-point projection as dependency injection, a design pattern that enables library-level CP in host languages without support for monads. Third, we propose census polymorphism, a technique for abstracting over the number of participants in a choreography. We demonstrate these contributions via implementations in Haskell, Rust, and TypeScript.
翻译:编排式编程是一种用于实现分布式系统的范式,它使用单一的全局程序来定义所有参与者的动作和交互。库级别的编排式编程实现(如HasChor)能够很好地与主流编程语言集成,但存在若干局限性:其条件语句需要额外的通信;它们需要特定的宿主语言特性(例如单子);并且缺乏对实现实际分布式应用至关重要的编程模式的支持。我们针对库级别编排式编程提出了三项贡献,专门应对这些挑战。首先,我们提出并形式化了"围场"和"多位置值",使得库级别编排式编程中的条件语句无需冗余通信即可高效实现。其次,我们提出将端点投影作为依赖注入,这是一种设计模式,使得库级别编排式编程能够在无需单子支持的宿主语言中实现。第三,我们提出人口普查多态,这是一种对编排中参与者数量进行抽象的技术。我们通过Haskell、Rust和TypeScript中的实现来展示这些贡献。