8

For use with a class I'll be teaching, I'm looking for a fast compiler or bytecode interpreter for Standard ML. I'm looking for fast compile times; any reasonable run time will do. Bonus if the compilation model is simple and clear. Students in the class will also be using MLton to generate good binaries, but MLton is slow to compile and there are times when students need something they can interact with.

Here's what I know already:

  • Standard ML of New Jersey has an interactive read-eval-print-loop, but its compilation rules are a bit strange, and it's a bit slow. Still, it may be the leading contender.

  • Moscow ML used to be ideal, but it still has not been brought up to date with the 2004 Standard Basis Library. Most unfortunate, because in addition to its many other fine properties, Moscow ML also has an interactive help system—but I can't inflict on my students a compiler whose libraries do something different from what all the online documentation says.

  • Poly/ML might well fit the bill, except that looking at the documentation online, I can't figure out how to get it to compile. That might be OK.

At the moment it looks as if either SML/NJ or Poly/ML would be the best compromise. It has been many years since I did any serious work in Standard ML, and I would welcome information about other compilers or which of these alternatives is, in your experience, the fastest to interact and the easiest to learn to use.

Norman Ramsey
  • 198,648
  • 61
  • 360
  • 533

3 Answers3

10

Poly/ML seems to be a little faster than SML/NJ. For example, compiling HaMLet (approx. 25850 lines of commented SML) with Poly/ML, SML/NJ, and MLton, I get the following:

[mtf@fenrir hamlet-1.3.1.polyml]$ /usr/bin/time make with-poly
...
        2.92 real         2.31 user         0.55 sys
[mtf@fenrir hamlet-1.3.1.smlnj]$ /usr/bin/time make with-smlnj
...
       11.98 real        11.08 user         0.78 sys
[mtf@fenrir hamlet-1.3.1.mlton]$ /usr/bin/time make with-mlton
...
       24.51 real        21.04 user         3.05 sys

The difference between Poly/ML and SML/NJ isn't quite as pronounced when compiling MLton (approx. 175779 lines of commented SML):

[mtf@fenrir mlton.polyml]$ /usr/bin/time make polyml-mlton
...
      117.67 real       112.12 user         4.87 sys
[mtf@fenrir mlton.smlnj]$ /usr/bin/time make smlnj-mlton
...
      123.31 real       116.24 user         6.38 sys
[mtf@fenrir mlton.mlton]$ /usr/bin/time make mlton-compile
...
      238.44 real       232.01 user         5.49 sys

As REPLs, Poly/ML and SML/NJ are nearly equivalent. I find the error messages from SML/NJ to be a little bit better; they tend to have more specific source locations. Of course, when used as a REPL, SML/NJ's source locations are in terms of stdIn, for which line numbers aren't terribly helpful.

If your students are only ever going to use the REPL or compile single-file programs, then I would imagine that either Poly/ML or SML/NJ would serve your purposes. Both provide the SML use function. Multi-file programs are probably best served by SML/NJ's Compilation Manager or MLton's ML Basis System; Poly/ML provides yet another compilation system (PolyML.make), but I've never used it.

What difficulties do you have with compiling Poly/ML? Since version 5.0, Poly/ML has supported a simple ./configure ; make ; make install build. Using Poly/ML 5.X to compile a standalone executable requires using PolyML.export and invoking a C compiler, but is fairly well described in the version 5.0 release notes.

Matthew Fluet
  • 116
  • 1
  • 2
  • I've had no difficulties compiling Poly/ML; I just installed the Debian package. It's the "yet another compilation system" that I'm having trouble figuring out. I very much want the students to be able to use a model they're familiar with---compile source to get an executable binary---but with something a little faster than MLton. Perhaps I should download HaMLet and see how the Makefile is set up. +1 – Norman Ramsey Jul 08 '10 at 20:13
  • 1
    Both HaMLet and MLton (and Isabelle AFAICT) drive Poly/ML via the `use` function. I don't know of any project (besides Poly/ML itself) that uses the PolyML.make facility. You could ask for pointers on the Poly/ML mailing list; its low traffic, but responsive. – Matthew Fluet Jul 08 '10 at 20:46
  • 1
    Isabelle/ML uses the very convenient PolyML.Compiler structure to implement its own variant of `use`, such that the effect on the ML enfironment is managed internally, e.g. to allow undo/rollback of the static environment. – Makarius Mar 01 '13 at 22:52
3

I appreciate that this is a very late answer to the question, but there is a Moscow ML project on github with an updated Basis Library. It's at https://github.com/kfl/mosml/ (with an update in November 2012!)

I have also got code that implements much of the new Basis Library for Moscow ML so that I can use both it and Poly/ML to implement HOL4. The code for that is all inside http://github.com/mn200/HOL, and could be dug out if you wanted it.

Michael Norrish
  • 412
  • 2
  • 11
1

There's an LLVM port of Moscow ML. I don't know if it's usable for all purposes yet, but with regard to speed it should be better than the old camlrunm.

Maybe it's worth the time for you to port the feature which you think is differs from the code in the documentation. I'm sure the Moscow ML maintainers will appreciate it.

I didn't find a difference in the documentation which comes with Moscow ML and the actual implementation, but I didn't do any big projects in Standard ML. I think it would be helpful if you could give an example where the Moscow ML documentation differs from the implementation. This would also interest me.

  • Library modules `TextIO`, `Array`, and `Vector` don't conform to the standard. I have been after the Moscow ML people about this for *years*, and they basically don't care. If they don't care about improving their software, why should I? On another note, maybe my question wasn't clear, but I care about **fast compile times**. Any plausible run time is just fine with me. – Norman Ramsey Jul 12 '10 at 02:59
  • I will see what I can do about the standard conformance of the standard libraries. It seems to be a useful job. I think the main problem with Moscow ML is that it seems to be abandoned by its original maintainers. With the LLVM port it gained a bit of momentum when two Danish students began touching it after nearly a decade, but this also seems to have stalled. I think Standard ML lost a lot of (potential) users and researchers to Haskell. Maybe this is why nobody cares that much anymore. –  Jul 13 '10 at 17:12
  • I actually gave the wrong link to the exsml repository. I corrected it. –  Jul 13 '10 at 17:15
  • Can you look at http://github.com/jlouis/exsml/tree/master/exsmllib/ and see whether the problems with the standard conformance were solved? –  Jul 13 '10 at 17:29
  • They were not. In fact, that project is currently rotting like hell because I don't have time to build an LLVM backend. Nowadays, I'd probably start from Poly/ML which is a better base. – I GIVE CRAP ANSWERS Jun 30 '14 at 19:46