Skip to main content
QUICK REVIEW

[Paper Review] Mixing the Objective Caml and C# Programming Models in the .Net Framework

Emmanuel Chailloux, Grégoire Henry|arXiv (Cornell University)|May 10, 2007
Logic, programming, and type systemsComputer Science3 references3 citations
TL;DR

This paper presents O’Jacaré.net, a code generator that enables seamless inter-operation between Objective Caml and C# on the .NET Framework by defining a shared IDL (Interface Definition Language) for interoperability. It generates wrapper classes to bridge the semantic and type differences between Caml's functional object model and C#'s class-based model, enabling cross-language late binding, type-safe communication, and mutual access to libraries while preserving static typing in both languages.

ABSTRACT

We present a new code generator, called O'Jacare.net, to inter-operate between C# and Objective Caml through their object models. O'Jacare.net defines a basic IDL (Interface Definition Language) that describes classes and interfaces in order to communicate between Objective Caml and C#. O'Jacare.net generates all needed wrapper classes and takes advantage of static type checking in both worlds. Although the IDL intersects these two object models, O'Jacare.net allows to combine features from both.

Motivation & Objective

  • To enable seamless interoperability between Objective Caml and C# on the .NET Framework despite their divergent object models and type systems.
  • To preserve static type safety and full type inference from Objective Caml while enabling access to C# libraries and runtime features.
  • To allow mutual use of components—C# code to call Caml objects and vice versa—without modifying the Caml compiler or runtime.
  • To address the challenge of combining Caml's open, polymorphic object system with C#'s class-based, statically-typed model in a unified, type-safe way.
  • To provide a practical, extensible solution for integrating functional and imperative programming models within the .NET ecosystem.

Proposed method

  • Designing a minimal, shared IDL (Interface Definition Language) to describe classes and interfaces that are interoperable between Objective Caml and C#.
  • Generating wrapper classes automatically from the IDL to mediate between Caml's open, polymorphic object types and C#'s nominal, class-based types.
  • Using late binding for method dispatch in both directions, enabling dynamic method resolution across language boundaries.
  • Implementing type coercion functions in Caml to safely perform downcasts from a common root type (top) to specific C#-derived types.
  • Leveraging the .NET Common Type System (CTS) and Common Language Runtime (CLR) to ensure type safety and interoperability at runtime.
  • Extending the O'Jacaré framework (originally for Java) to support C# and .NET, adapting it to the managed code model of OCamIL.

Experimental results

Research questions

  • RQ1How can two programming languages with fundamentally different object models—Objective Caml's open, polymorphic objects and C#'s nominal, class-based objects—be made to interoperate safely and efficiently on the .NET platform?
  • RQ2To what extent can static type safety be preserved when bridging Caml's type inference and C#'s static typing across language boundaries?
  • RQ3Can a shared IDL be designed to express mutual dependencies between Caml and C# components without requiring mutual recursion or type cycles?
  • RQ4What are the limitations of current interoperability patterns when components depend on each other (e.g., mutual recursion), and how can they be overcome?
  • RQ5How can advanced .NET features such as delegates, generics, and event handling be exposed through the interoperability layer without breaking type safety?

Key findings

  • O’Jacaré.net successfully enables bidirectional interoperability between Objective Caml and C# using a shared IDL and automatic wrapper generation.
  • The system preserves static type checking in both languages, ensuring type safety even across language boundaries.
  • Late binding is supported in both directions, allowing dynamic method dispatch between Caml and C# objects.
  • Downcasting from a common root type (top) to specific C#-derived types is implemented via safe type coercion functions that raise exceptions on type mismatches.
  • The ray-tracer case study demonstrates end-to-end interoperability: a Caml-based rendering engine can be driven by a C# GUI, with pixel rendering callbacks working across the boundary.
  • A key limitation arises in mutually recursive components (e.g., C# Display class requiring a Caml Render class and vice versa), where the current IDL model cannot express mutual dependencies without type errors due to lack of inheritance between original and wrapped types.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.