Cross-Language Interoperability in a Multi-Language Runtime
Open Access
- 28 May 2018
- journal article
- research article
- Published by Association for Computing Machinery (ACM) in ACM Transactions on Programming Languages and Systems
- Vol. 40 (2) , 1-43
Abstract
In large-scale software applications, programmers often combine different programming languages because this allows them to use the most suitable language for a given problem, to gradually migrate existing projects from one language to another, or to reuse existing source code. However, different programming languages have fundamentally different implementations, which are hard to combine. The composition of language implementations often results in complex interfaces between languages, insufficient flexibility, or poor performance. We propose TruffleVM, a virtual machine (VM) that can execute different programming languages and is able to compose them in a seamless way. TruffleVM supports dynamically-typed languages (e.g., JavaScript and Ruby) as well as statically typed low-level languages (e.g., C). It consists of individual language implementations, which translate source code to an intermediate representation that is executed by a shared VM. TruffleVM composes these different language implementations via generic access . Generic access is a language-agnostic mechanism that language implementations use to access foreign data or call foreign functions. It features language-agnostic messages that the TruffleVM resolves to efficient foreign-language-specific operations at runtime. Generic access supports multiple languages, enables an efficient multi-language development, and ensures high performance. We evaluate generic access with two case studies. The first one explains the transparent composition of JavaScript, Ruby, and C. The second one shows an implementation of the C extensions application programming interface (API) for Ruby. We show that generic access guarantees good runtime performance. It avoids conversion or marshalling of foreign objects at the language boundary and allows the dynamic compiler to perform its optimizations across language boundaries.Keywords
This publication has 45 references indexed in Scilit:
- Memory-safe Execution of C on a Java VM2015
- The challenge of cross-language interoperabilityCommunications of the ACM, 2013
- Rigorous benchmarking in reasonable time2013
- Compilation queuing and graph caching for dynamic compilers2012
- Virtual machines should be invisible2011
- Debug all your codeACM SIGPLAN Notices, 2009
- Safe Cross-Language Inheritance2008
- No-Longer-Foreign: Teaching an ML compiler to speak C “natively”Electronic Notes in Theoretical Computer Science, 2001
- Lightweight remote procedure callACM Transactions on Computer Systems, 1990
- How not to lie with statistics: the correct way to summarize benchmark resultsCommunications of the ACM, 1986