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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With