The .NET platform claims to be a melting pot that allows the integration of different languages in a common framework, sharing a common type system, CTS, and a runtime environment, CLR (Common Language Runtime). Each .NET compiler generates portable MSIL byte-code (MicroSoft Intermediate Language). By assuming compliance to the CTS type system, components inter-operate safely.
The .NET framework is actually well suited for object-oriented languages which have an object model close to the one of C# or Java. Unfortunately, languages with other kinds of object models, type systems or supporting different programming paradigms (such as functional programming .. . ) do not fit in .NET as well as C# does. Writing .NET compilers for them requires much more efforts.
However, the .NET framework still gives us a good opportunity to experiment interoperability between two languages as different as Objective Caml[1] (shortened as O’Caml) and C#. O’Caml is an ML dialect: it is a functional/imperative statically typed language, featuring parametric polymorphism, an exception mechanism, an object layer and parameterized modules. By achieving interoperability, each language gains access to a wider set of libraries and programmers take advantage of a richer programming model.
We use the experimental OCamIL compiler[2], which compiles the whole O’Caml distribution (including toplevel) to .NET managed code. We intend to communicate between O’Caml and C# by means of their respective object models. Difficulties arise because neither the type system nor the object model of O’Caml natively fit in the CTS. O’Caml objects cannot be directly compiled to CTS objects. Communication cannot be direct: C# and O’Caml objects have to be interfaced. We use an IDL (Interface Description Language) and a code generator called O’Jacare.net. It is based on our previous work[3] on interoperability of O’Caml and Java.
We first describe the O’Caml object model and compare it to the C# model. We then introduce O’Jacare.net, using a small example as an illustration of its features. The last section is dedicated to expressiveness issues. We show that the combination of two object models allows to take advantage of features of both, and also discuss the current limitations of O’Jacare.net, giving hints on how they can be solved in further developments.
Download pdf Mixing the Objective Caml and C# Programming Models in the .NET Framework
Related Searches: interface description language, objective caml, object oriented languages, parameterized modules, programming paradigms
RSS feed for comments on this post · TrackBack URI
Leave a reply