Foundations for polylingual systems

One of the realities of programming is that some programming languages are better suited for particular tasks than others. As a result programmers would like to write different portions of a program in different languages. The problem is that interoperation of programming language systems is hard and error-prone. Consider the case of interoperating between C++ and Java. These are very similar languages in many ways, yet the manual for the Java Native Interface (JNI) Liang [1999] runs to some 320 pages. The programmer must understand not only the programming languages involved but also the complex interactions between the language systems. In this dissertation we will illustrate the problem with an extremely simple example that behaves nicely when written in either language but dies an ugly death when written with pieces in both. The problem with this sample is that the “glue code” that the programmer had to write to enable the interoperation was unsound. Furthermore, the very fact that the programmer had to write glue code is problematic. We promote a style of interoperation referred to as polylingual programming, in which the programmer need not be aware that some portions of the program are written in other languages. To enable this we will need to automate the process of crossing language system boundaries, without running into the problems mentioned above. Our approach is to use formal techniques to understand the problems of interoperation, and then to create tools informed by those results to generate interface code. We have designed a formal language called J suited for analysis of interoperation issues. We formally present the syntax, typing rules, and semantics of this language with an automated proof of type-safety. We then show how this language is used in analyzing interoperation issues, and present a tool we have created, based on the formal results, for assisting in the interoperation of Java and C++. Finally, we present a tool that we developed to assist us in designing and analyzing J . This tool takes a single description of a programming language and produces the multiple representations needed in the research.