Standard ML is a call-by-value, statically-typed, impure functional programming language with an advanced module system.
I was a co-author of the MLj compiler that targeted the Java Virtual Machine. I now work on the SML.NET compiler, which targets the .NET Common Language Runtime, provides seamless interoperability with .NET libraries, and is integrated into the Visual Studio development environment.
The SML.NET Compiler
The MLj Compiler
Compiling with Continuations, Continued
Andrew Kennedy. In Proceedings of the International Conference on Functional Programming (ICFP) 2007.
Slides from talk.
We present a series of CPS-based intermediate languages suitable for functional language compilation, arguing that they have practical benefits over direct-style languages based on A-normal form (ANF) or monads. Inlining of functions demonstrates the benefits most clearly: in ANF-based languages, inlining involves a re-normalization step that rearranges let expressions and possibly introduces a new `join point' function, and in monadic languages, commuting conversions must be applied; in contrast, inlining in our CPS language is a simple substitution of variables for variables.
We present a contification transformation implemented by simple rewrites on the intermediate language. Exceptions are modelled using so-called `double-barrelled' CPS. Subtyping on exception constructors then gives a very straightforward effect analysis for exceptions. We also show how a graph-based representation of CPS terms can be implemented extremely efficiently, with linear-time term simplification.
Shrinking Reductions in SML.NET
Nick Benton, Andrew Kennedy, Sam Lindley and Claudio Russo. In Proceedings of the 16th International Workshop on Implementation and Application of Functional Languages (IFL '04). September 2004. Springer Lecture Notes in Computer Science, 2005 (to appear). A preliminary version appeared in the Draft Proceedings of IFL'04, Technical Report 0408, Institute of Computer Science and Applied Mathematics, University of Kiel.
One performance-critical phase in the SML.NET compiler involves rewriting intermediate terms to monadic normal form and performing non-duplicating β-reductions. We present an imperative algorithm for this simplification phase, working with a mutable, pointer-based term representation, which significantly outperforms our existing functional algorithm. This is the first implementation and evaluation of a linear-time rewriting algorithm proposed by Appel and Jim.
Adventures in Interoperability: The SML.NET Experience.
Nick Benton, Andrew Kennedy and Claudio Russo. 6th ACM-SIGPLAN International Conference on Principles and Practice of Declarative Programming (PPDP), Verona, Italy, August 2004.
SML.NET is a compiler for Standard ML that targets the Common Language
Runtime and is integrated into the Visual Studio development environment. It
supports easy interoperability with other .NET languages via a number of
language extensions, which go considerably beyond those of our earlier compiler,
This paper describes the new language extensions and the features of the Visual Studio plugin, including syntax highlighting, Intellisense, continuous type inference and debugger support. We discuss our experiences using SML.NET to write SML programs that interoperate with other .NET languages, libraries and frameworks. Examples include the Visual Studio plugin itself (written in SML.NET, using .NET's COM interop features to integrate in a C++ application) and writing ASP.NET and Pocket PC applications in SML.
Nick Benton and Andrew Kennedy. In Journal of Functional Programming, 11(4): 395-410, July 2001.
From the points of view of programming pragmatics, rewriting and operational
semantics, the syntactic construct used for exception handling in ML-like
programming languages, and in much theoretical work on exceptions, has subtly
undesirable features. We propose and discuss a more well-behaved construct.
Working Without Tears: Blending SML with Java
Nick Benton and Andrew Kennedy. In Proceedings of the 4th ACM SIGPLAN International Conference on Functional Programming, Paris, France, September 1999.
A good foreign-language interface is crucial for the success of any modern programming language implementation. Although all serious compilers for functional languages have some facility for interlanguage working, these are often limited and awkward to use.
This article describes the features for bidirectional interlanguage working with Java that are built into the latest version of the MLj compiler. Because the MLj foreign interface is to another high-level typed language which shares a garbage collector with compiled ML code, and because we are willing to extend the ML language, we are able to provide unusually powerful, safe and easy to use interlanguage working features. Indeed, rather then being a traditional foreign interface, our language extensions are more a partial integration of Java features into SML.
We describe this integration of Standard ML and Java, first informally with example program fragments, and then formally in the notation used by The Definition of Standard ML.
Compiling Standard ML to Java Bytecodes
Nick Benton, Andrew Kennedy, and George Russell. In Proceedings of the 3rd ACM SIGPLAN International Conference on Functional Programming, Baltimore, Maryland, USA, September 1998.
MLJ compiles SML'97 into verifier-compliant Java bytecodes. Its features include type-checked interlanguage working extensions which allow ML and Java code to call each other, automatic recompilation management, compact compiled code and runtime performance which, using a `just in time' compiling Java virtual machine, usually exceeds that of existing specialised bytecode interpreters for ML. Notable features of the compiler itself include whole-program optimisation based on rewriting, compilation of polymorphism by specialisation, a novel monadic intermediate language which expresses effect information in the type system and some interesting data representation choices.
Don Syme's F# compiler.
Both MLj and SML.NET were developed using the Standard ML of New Jersey compiler.