As seen on the LLVMdev mailing list: Jon Harrop, Fibonacci example in OCaml:
Here is a complete 104-line native code compiler for a tiny subset of OCaml that is expressive enough to compile an external Fibonacci program:
[...]
The compiler is itself written in OCaml, of course; for those who don’t know, OCaml or Objective Caml is an object-oriented dialect of Standard ML, a purely functional language.
Jon’s name rang a bell because I just listened to the second of two podcasts from .NET Rocks on the F# functional programming language — Jon Harrop Makes Us F# and F# Moves Forward — that Microsoft will be including with future versions of VIsual Studio. F# is itself a derivative of OCaml, runs atop the .NET Common Language Runtime, and can interoperate with other code
F# is interesting because, due to its functional and side-effect-free nature, one can get a huge amount of parallelism out of straightforward code. (It’s the lack of side effects that allow such analysis to be performed.) The Xbox Live matching service, for example, is using a TrueSkill engine developed in F# by Microsoft Research.
OCaml on LLVM is interesting in a lot of the same ways: You have a functional language that’s very amenable to all sorts of analysis and optimization, and an abstract platform that can run on an extremely wide variety of systems very efficiently. It’s really the best of both worlds, where you will be able to write the parts of your software that need to be highly parallel and mathematically rigorous in a language amenable to it, and interface that to the rest of your application in a very natural fashion.
It’s great to see that Jon is enjoying exploring OCaml atop LLVM and I can’t wait to see what kind of fun results!