Multi-language virtual machines have a number of advantages. They allow software developers to use software libraries that were written for different programming languages. Furthermore, language implementors do not have to bother with low-level VM functionality and their implementation can benefit from optimizations in existing virtual machines. MagLev is an implementation of the Ruby programming language on top of the GemStone S virtual machine for the Smalltalk programming language. In this work, we present how software components written in both languages can interact. We show how MagLev unifies the Smalltalk and the Ruby object model, taking into account Smalltalk meta classes, Ruby singleton classes, and Ruby modules. Besides, we show how we can call Ruby methods from Smalltalk and vice versa. We also present MagLev's concept of bridge methods for implementing Ruby method calling conventions. Finally, we compare our solution to other language implementations and virtual machines.
Common Language Specification The CLS is a set of rules that is important for language implementors and application developers. Some programming languages offer features that are not supported in other programming languages. For example, according to Hamilton, incompatible types are the primary barriers that keep languages from interoperating'' @cite_3 . The CLS ensures that CLS-compliant components can interact with each other, e.g. by defining a set of data types that all CLS-compliant languages support. Language implementors have to support these data types to call their implementation CLS-compliant and their compilers must generate CLS-compliant artifacts that do not use other data types in their public interface.
@cite_3
1963914916 1599235838 2020899082 2114568665
The Common Language Runtime (CLR) is language and platform-neutral, and provides the underlying infrastructure for the Microsoft .NET Framework. A key innovation in the CLR is its support for multiple programming languages, enabling programming language integration at the runtime level to a much greater degree than is currently possible. The implementation of statically typed programming languages on the .NET Common Language Infrastructure (CLI) is by now well understood (Gough 2002). However, the situation with dynamic languages is not so clear. Typically such languages have objects that are dynamically typed, while the CLI is statically typed at the instruction code level. Nevertheless there is a growing body of evidence suggesting that the CLI can be a suitable target for such languages (Hugunin 2006). In order to better understand the issues involved we set out to create a full implementation of the Ruby language on the CLI. This paper describes the challenges faced and design decisions made in creating Ruby.NET -- a Ruby compiler for the CLI. 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. A rule-based language is proposed for product configuration applications. It is equipped with a declarative semantics providing formal definitions for main concepts in product configuration, including configuration models, requirements and valid configurations. The semantics uses Horn clause derivability to guarantee that each element in a configuration has a justification. This leads to favorable computational properties. For example, the validity of a configuration can be decided in linear time and other computational tasks remain in NP. It is shown that CSP and dynamic CSP can be embedded in the proposed language which seems to be more suitable for representing configuration knowledge. The rule language is closely related to normal logic programs with the stable model semantics. This connection is exploited in the first implementation which is based on a translator from rules to normal programs and on an existing high performance implementation of the stable model semantics, the Smodels system.