The development of software applications using multiple programming languages has increased in recent years, as it allows the selection of the most suitable language and runtime for each component of the system and the integration of third-party libraries. However, this practice involves complexity and error proneness, due to the absence of an adequate system for the interoperability of multiple programming languages. Developers are compelled to resort to workarounds, such as library reimplementation or language-specific wrappers, which are often dependent on C as the common denominator for interoperability. These challenges render the use of multiple programming languages a burdensome and demanding task that necessitates highly skilled developers for implementation, debugging, and maintenance, and raise doubts about the benefits of interoperability. To overcome these challenges, we propose MetaFFI, a pluggable in-process indirect-interoperability system that allows the loading and utilization of entities from multiple programming languages. This is achieved by exploiting the less restrictive shallow binding mechanisms (e.g., Foreign Function Interface) to offer deep binding features (e.g., object creation, methods, fields). MetaFFI provides a runtime-independent framework to load and \emph{xcall} (Cross-Call) foreign entities (e.g., functions, objects). MetaFFI uses Common Data Types (CDTs) to pass parameters and return values, including objects and complex types, and even cross-language callbacks. The indirect interoperability approach of MetaFFI has the significant advantage of requiring only $2n$ mechanisms to support $n$ languages, as opposed to the direct interoperability approaches that need $n^2$ mechanisms. We have successfully tested the binding between Go, Python3.11, and Java in a proof-of-concept on Windows and Ubuntu.
翻译:近年来,使用多种编程语言开发软件应用的情况日益增多,因为这允许为系统的每个组件选择最合适的语言和运行时环境,并集成第三方库。然而,由于缺乏一个适用于多编程语言互操作的完善系统,这种做法带来了复杂性和易错性。开发者被迫采用变通方案,例如库的重实现或特定语言包装器,而这些方案通常依赖于C语言作为互操作的共同基础。这些挑战使得使用多种编程语言成为一项繁重且要求高的任务,需要高技能的开发者进行实现、调试和维护,并对互操作的优势产生质疑。为了克服这些挑战,我们提出了MetaFFI,一个可插拔的进程内间接互操作系统,允许加载和利用来自多种编程语言的实体。这是通过利用限制较少的浅绑定机制(例如,外部函数接口)来提供深绑定功能(例如,对象创建、方法、字段)实现的。MetaFFI提供了一个独立于运行时的框架,用于加载和\emph{xcall}(跨语言调用)外部实体(例如,函数、对象)。MetaFFI使用通用数据类型(CDTs)来传递参数和返回值,包括对象和复杂类型,甚至跨语言回调。MetaFFI的间接互操作方法具有显著优势,仅需$2n$种机制即可支持$n$种语言,而直接互操作方法则需要$n^2$种机制。我们已在Windows和Ubuntu系统上的概念验证中成功测试了Go、Python3.11和Java之间的绑定。