Sunday, 1 August 2010

The rise and fall of OCaml

After over 3 years, The OCaml Journal is finally closing down. New subscriptions offer access to the 75 existing articles and only a few more articles will be published, to honour outstanding subscriptions.

This marks Flying Frog Consultancy Ltd. officially pulling out of the OCaml market as our remaining OCaml products (such as the OCaml for Scientists book) require no on-going maintenance.

This change has, of course, come about due to a dramatic fall in our revenue from OCaml products since 2007. This is partly because we decided in 2007 to jump ship to Microsoft's new F# programming language. However, the same trend can be seen in the rate of posts to the OCaml mailing lists, which has fallen 60% since 2007 and has now reached its lowest level for a decade:

We blame the inability of OCaml's garbage collector to allow threads to run in parallel as the primary reason for this mass exodus. OCaml was an awesome tool in the late 1990s and, by 2004, many people were finding the OCaml language from benchmark results that showed it to be one of the fastest languages available. Ironically, that was largely due to the superior performance of OCaml's garbage collector but that same garbage collector is now a serious impediment to parallel programming on today's multicore machines. Coupled with advancements like monomorphization on .NET and LLVM-based backends with vastly better code generation like GHC, OCaml has been left in the dust. Consequently, the majority of OCaml programmers who had chosen it for performance reasons (many of whom were research scientists) are leaving.

OCaml also suffers from several other problems including the cumbersome FFI that requires separate C stubs and the lack of a native-code REPL. However, all of these problems could be addressed by developing a new VM. Indeed, at only 2kLOC our own HLVM project has demonstrated just how easy LLVM makes it to build a new high-performance multicore-capable VM for OCaml-like languages. We believe a complete replacement could be developed in just a few months but, sadly, nobody has done any work on this beyond our own tentative attempts with HLVM.

On the other hand, there was never any onus on an academic institution to create such a useful tool in the first place so it is important to remember that OCaml was only valuable thanks to the hard work and dedication of its academic creators. Thanks INRIA!


phil tomson said...

It sounds like you're not planning to continue work on HLVM. Is that the correct reading? If that is the case then why not?

Flying Frog Consultancy Ltd. said...

@Phil: Fun and money. I've done the interesting bits and all that remains is the hard work to build a viable platform out of it. Without funding, I cannot justify doing that hard work. Right now, my F# hobby projects are more fun and earning me a lot more money! :-)

Paolo said...

John, I really appreciate your opinions and your work in general, but this time I have to disagree with your feeling about the "fall" of OCaml. For sure OCaml will not be anymore your language of choice, for the good reasons you explained, but I see a raising interest in OCaml, not a fall. The number of posts in the mailing list is not so relevant, while the number of blog posts, and the number and quality of new projects written in OCaml is impressing, always keeping in mind that OCaml will never be a mainstream language.

The last OCaml meeting has been a real success, with 75 participants and an overall quality of the talks that impressed me.

In any case I hope you will stay in the OCaml community and continue to develop something in OCaml, if not for business, at least for pleasure :-)

Flying Frog Consultancy Ltd. said...

@Paolo: There are plenty of other metrics that show the same strong downward trend for OCaml. For example, Google trends shows that the proportion of Google searches that are for "OCaml" has fallen 80% in recent years when other languages like F# have risen sharply and overtook OCaml in 2007 (and it correlates very strongly with our revenue!). ITJobsWatch shows that the number of OCaml jobs was comparable to other functional languages like Scala, Haskell and F# back in 2007 but today there are only 6 OCaml jobs compared to 77-81 for the other languages.

Great to hear that the OCaml meeting was a success. I think OCaml is reinventing itself for concurrent programming where absolute performance and multicore are of little relevance. The language improvements in 3.12 look really nice as well.

scawa said...

I am just getting into FP after attending a lecture by Neal Ford. As a self taught developer (COBOL, Fortran, Jovial, C/C++ and Java), I've been involved in mostly imperative and OO languages. FP was interesting to me. I started looking into books on FP and found a lot of them used ML and OCaml for their examples.

Is this issue with GC threading still a problem? Jane Street still is pretty big on OCaml and they are using it for High Reliabilty, High Throughput software. Haven't found any discussions of this other than your blog.

Jon Harrop said...

@scawa: Yes, this is still very much a problem. OCaml still uses a global lock to prevent threads from running in parallel. The standard solution in OCaml is to fork processes but it is OS-specific and generally gives poor performance on multicores because the unnecessary copying saturates memory bandwidth and destroys scalability.

OCaml seems to be reinventing itself for applications where performance is not an issue.