开发者

Learning/using ML. Which system should i use?

I want to learn and use ML but there are many compile开发者_如何学Gors out there. I need:

  • speed
  • low memory usage
  • threading
  • mutable arrays and record types
  • continuations
  • ready for production code
  • easy ffi
  • up to date
  • ... helpful libraries
  • portable to some degree

I do not need:

  • objects
  • GUI
  • support for windows

For example I found OCaml, OCaml Batteries include and MLton. Any advice for me which one should I choose?


SML has better support for continuations. If you have a strong need for continuations, it is a better choice; OCaml has no in-language support for them, but there is the Delimcc library by Oleg for delimited continuations; being external, it is probably slower than SML's implementations. Otherwise, OCaml seems to have more traction these days, so you should expect the tooling and libraries to be slightly better.

More generally, SML tends to be rather more elegant, while OCaml has some more advanced features, quirks, and users. Performance-wise they're both good.

(See this for a syntactic comparison of the mostly-common fragments of both languages; of course OCaml's objects and polymorphic variants are not presented.)


Well for MLton:

  • Speed
    • The whole program optimisations definetley give you better speed than OCaml, however the penalty you serve for each and every recompile can be quite annoying. See this link for a simple informal comparison of MLton and OCaml
  • Threading
    • No problem here, you have either MLton.Thread or CML
  • Mutable arrays and record types
    • refs, arrays and records
  • Continuations
    • I haven't used it before, but it is present as in SML/NJ
  • ready for production code
    • Obviously depends on the libraries you use. But the basis library is solid, however MLton has its own additions and a few others have repos with extensions listed here. However the MLton library project contains some nice code. However as with many of such libraries/extensions, they tend to rely on other extensions made by them self and thus it is hard to only use small parts of them.
  • Easy ffi
    • ForeignFunctionInterface and NoLonger-FFI are great. I have however had speed issues with the NL-FFI on big C codebases, which I think is due to MLton not removing the phantom types complety. However this is just a guess, I might have done something wrong.
  • Portable to some degree
    • MLton features, Portability


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

There are many companies who use OCaml in production for all sort of things. Some of the companies are mentioned on the Caml consortium website.

I also recommend reading some excellent OCaml experience reports:

OCaml at Jane Street Capital

OCaml at XenSource

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜