Operational semantics for multi-language programs

Interoperability is big business, a fact to which .NET, the JVM, and COM can attest. Language designers are well aware of this, and they are designing programming languages that reflect it—for instance, SML.NET, F#, Mondrian, and Scala all treat interoperability as a central design feature. Still, current multi-language research tends not to focus on the semantics of these features, but only on how to implement them efficiently. In this article, we attempt to rectify that by giving a technique for specifying the operational semantics of a multi-language system as a composition of the models of its constituent languages. Our technique abstracts away the low-level details of interoperability like garbage collection and representation coherence, and lets us focus on semantic properties like type-safety, equivalence, and termination behavior. In doing so it allows us to adapt standard theoretical techniques such as subject-reduction, logical relations, and operational equivalence for use on multi-language systems. Generally speaking, our proofs of properties in a multi-language context are mutually referential versions of their single language counterparts. We demonstrate our technique with a series of strategies for embedding a Scheme-like language into an ML-like language. We start by connecting very simple languages with a very simple strategy, and work our way up to languages that interact in sophisticated ways and have sophisticated features such as polymorphism and effects. Along the way, we prove relevant results such as type-soundness and termination for each system we present using adaptations of standard techniques. Beyond giving simple expressive models, our studies have uncovered several interesting facts about interoperability. For example, higher-order function contracts naturally emerge as the glue to ensure that interoperating languages respect each other's type systems. Our models also predict that the embedding strategy where foreign values are opaque is as expressive as the embedding strategy where foreign values are translated to corresponding values in the other language, and we were able to experimentally verify this behavior using PLT Scheme's foreign function interface.

[1]  S. Zdancewic,et al.  Principals in Programming Languages: A Syntactic Proof Technique , 1999, ICFP.

[2]  Nick Benton,et al.  Adventures in interoperability: the SML.NET experience , 2004, PPDP '04.

[3]  Robert Hieb,et al.  The Revised Report on the Syntactic Theories of Sequential Control and State , 1992, Theor. Comput. Sci..

[4]  Riccardo Pucella,et al.  A framework for interoperability , 2001, Electron. Notes Theor. Comput. Sci..

[5]  Nigel Perry,et al.  Scripting .NET Using Mondrian , 2001, ECOOP.

[6]  Benjamin C. Pierce,et al.  Logical relation for encryption , 2003 .

[7]  Amal Ahmed,et al.  Parametric Polymorphism through Run-Time Sealing or, Theorems for Low, Low Prices! , 2008, ESOP.

[8]  Cormac Flanagan,et al.  Hybrid type checking , 2006, POPL '06.

[9]  Jeffrey S. Foster,et al.  Checking type safety of foreign function calls , 2008, ACM Trans. Program. Lang. Syst..

[10]  Fritz Henglein,et al.  Safe polymorphic type inference for a dynamically typed language: translating Scheme to ML , 1995, FPCA '95.

[11]  Matthias Felleisen,et al.  On the Expressive Power of Programming Languages , 1990, ESOP.

[12]  Benjamin C. Pierce,et al.  A bisimulation for dynamic sealing , 2004, Theor. Comput. Sci..

[13]  Matthias Felleisen,et al.  A Visual Environment for Developing Context-Sensitive Term Rewriting Systems , 2004, RTA.

[14]  Robert Bruce Findler,et al.  Fine-grained interoperability through mirrors and contracts , 2005, OOPSLA '05.

[15]  Pedro Pinto,et al.  Dot-Scheme A PLT Scheme FFI for the .NET framework , 2003 .

[16]  Paul A. Steckler,et al.  MysterX: a Scheme toolkit for building interactive applications with COM , 1999, Proceedings of Technology of Object-Oriented Languages and Systems - TOOLS 30 (Cat. No.PR00278).

[17]  Matthias Felleisen,et al.  Contracts for higher-order functions , 2002, ICFP '02.

[18]  Robert Bruce Findler,et al.  Operational semantics for multi-language programs , 2007, POPL '07.

[19]  Matthias Blume No-Longer-Foreign: Teaching an ML compiler to speak C "natively" , 2001, Electron. Notes Theor. Comput. Sci..

[20]  Matthias Felleisen,et al.  A Syntactic Approach to Type Soundness , 1994, Inf. Comput..

[21]  Kazuhiko Kato,et al.  Semantics for communication primitives in a polymorphic language , 1993, POPL '93.

[22]  Bernard Robinet,et al.  Combinators and functional programming languages : Thirteenth Spring School of the LITP, Val d'Ajol, France, May 6-10, 1985, proceedings , 1986 .

[23]  John C. Reynolds,et al.  Types, Abstraction and Parametric Polymorphism , 1983, IFIP Congress.

[24]  Dan Grossman,et al.  Principals in programming languages: a syntactic proof technique , 1999, ICFP '99.

[25]  Dan Grossman,et al.  Syntactic type abstraction , 2000, TOPL.

[26]  John Clements,et al.  Laziness without all the hard work: combining lazy and strict languages for teaching , 2005, FDPE '05.

[27]  Carolyn L. Talcott,et al.  1 Equivalence in Functional Languages with E ectsIan , 2007 .

[28]  Zhong Shao,et al.  Safe and Principled Language Interoperation , 1999, ESOP.

[29]  Leif Kornstaedt Alice in the Land of Oz - An Interoperability-based Implementation of a Functional Language on Top of a Relational Language , 2001, Electron. Notes Theor. Comput. Sci..

[30]  Riccardo Pucella Towards a formalization for COM part i: the primitive calculus , 2002, OOPSLA '02.

[31]  David M. Beazley,et al.  SWIG: An Easy to Use Tool for Integrating Scripting Languages with C and C++ , 1996, Tcl/Tk Workshop.

[32]  Matthias Felleisen,et al.  A Syntactic Theory of Sequential Control , 1987, Theor. Comput. Sci..

[33]  Norman Ramsey,et al.  Embedding an interpreted language using higher-order functions and types , 2003, IVME '03.

[34]  Simon L. Peyton Jones,et al.  Calling hell from heaven and heaven from hell , 1999, ICFP '99.

[35]  Eli Barzilay,et al.  Foreign Interface for PLT Scheme , 2004 .

[36]  Andrew D. Gordon,et al.  Typing a multi-language intermediate code , 2001, POPL '01.

[37]  Benjamin C. Pierce,et al.  Relating Cryptography and Polymorphism , 2000 .

[38]  Amr Sabry,et al.  Reasoning about programs in continuation-passing style , 1992, LFP '92.

[39]  Benjamin C. Pierce,et al.  Types and programming languages: the next generation , 2003, 18th Annual IEEE Symposium of Logic in Computer Science, 2003. Proceedings..

[40]  Fritz Henglein,et al.  Dynamic Typing: Syntax and Proof Theory , 1994, Sci. Comput. Program..

[41]  G.D. Plotkin,et al.  LCF Considered as a Programming Language , 1977, Theor. Comput. Sci..

[42]  Andrew Kennedy Securing the .NET programming model , 2006, Theor. Comput. Sci..

[43]  Clemens A. Szyperski,et al.  The COMEL Language , 1997 .

[44]  Robert Bruce Findler,et al.  Contracts as Pairs of Projections , 2006, FLOPS.

[45]  Benjamin C. Pierce,et al.  Logical relations for encryption , 2001, Proceedings. 14th IEEE Computer Security Foundations Workshop, 2001..

[46]  J. Girard,et al.  Proofs and types , 1989 .

[47]  Manuel M. T. Chakravarty,et al.  The haskell 98 foreign function interface 1 , 2003 .

[48]  Daniel Silva,et al.  From Python to PLT Scheme , 2004 .

[49]  William W. Tait,et al.  Intensional interpretations of functionals of finite type I , 1967, Journal of Symbolic Logic.

[50]  Nick Benton,et al.  Under Consideration for Publication in J. Functional Programming Embedded Interpreters , 2022 .

[51]  Nick Benton,et al.  Interlanguage working without tears: blending SML with Java , 1999, ICFP '99.