Learning / using ML. Which system should I use?

I want to learn and use ML, but there are many compilers. I need:

  • speed
  • low memory usage
  • thread-cutting
  • mutable arrays and record types
  • sequels
  • production ready code
  • easy ffi
  • relevant
  • ... useful libraries
  • portable to some extent

I do not need:

  • objects
  • GUI
  • window support

For example, I found OCaml , OCaml batteries include MLton . Any advice for me that I should choose?

+8
sml ocaml ml
source share
3 answers

Good for MLton:

  • Speed
    • Optimizing the whole program definitely gives you better speed than OCaml, but the penalty for each recompilation can be quite annoying. See this link for a simple informal comparison of MLton and OCaml.
  • Thread cutting
  • Variable Arrays and Record Types
  • Continuation
  • production ready code
    • Obviously, this depends on the libraries you use. But the core library is solid, however MLton has its own add-ons, and some others have repositions with the extensions listed here . However, the MLton library project contains good code. However, as with many of these libraries / extensions, they usually rely on other extensions created by themselves, and therefore it is difficult to use only small parts of them.
  • Easy ffi
    • ForeignFunctionInterface and NoLonger-FFI are great. However, I had performance issues with NL-FFI on large C codes, which, in my opinion, is due to the fact that MLton does not remove phantom types. However, this is just an assumption; I could do something wrong.
  • Portable to some extent
+5
source share

SML has better support for follow-ups. If you have a strong need for follow-ups, this is the best choice; OCaml does not support language support for them, but there is also Oleg Delimcc library for limited sequels; being external, it is probably slower than the SML implementation. Otherwise, OCaml seems to have a lot of traction these days, so you should expect tools and libraries to be a little better.

More generally, SML tends to be more elegant, while OCaml has a few additional features, quirks, and users. They are both good in performance.

(see this for a syntactic comparison of the most common fragments of both languages, of course, OCaml objects and polymorphic variants are not presented.)

+9
source share

Ocaml satisfies all the requirements on your list, with the exception of the sequels. It is fast, memory efficient, portable, has posix thread bindings and good libraries for lightweight shared threads. The standard library is quite limited, but there are many third-party libraries .

There are many companies that use OCaml in production for all kinds of things. Some of the companies are mentioned on the Caml website.

I also recommend reading excellent OCaml performance reports:

OCaml at Jane Street Capital

OCaml at XenSource

+5
source share

All Articles