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 enclaves 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.
翻译:编排式编程(Choreographic Programming,CP)是一种用于实现分布式系统的范式,它通过单一的全局程序来定义所有参与者的动作和交互。库级别的CP实现(如HasChor)能够很好地与主流编程语言集成,但也存在若干局限性:其条件判断需要额外的通信;它们需要特定的宿主语言特性(例如单子);并且缺乏对实现实际分布式应用至关重要的编程模式的支持。我们针对库级别CP提出了三项改进,专门应对这些挑战。首先,我们提出并形式化了“飞地”和“多重定位值”,使得库级别CP中的条件判断能够高效进行,无需冗余通信。其次,我们提出将端点投影作为依赖注入,这是一种设计模式,使得库级别CP能够在无需单子支持的宿主语言中实现。第三,我们提出了“人口普查多态性”,这是一种对编排中参与者数量进行抽象的技术。我们通过Haskell、Rust和TypeScript中的实现展示了这些贡献。