Question

I really liked learning ML at college. I find functional programming often a refreshingly elegant way to write certain algorithms. I have heard of F# and played around with that a bit. Still, I've written some interesting functions in ML and would like to integrate them as libraries I could use in other applications.

Usually I paste my functions into the SMLnj interpreter. Is there a way I can compile them down?

Was it helpful?

Solution

You will have to use something like the MLj Compiler. It compiles to Java Byte code. Or you can use the SML.NET compiler to compile to .NET IL.

OTHER TIPS

It is common amongst ML for both sides to export to C and then call each others C functions. Just about everything has a FFI library for 'easily' exporting to C.

http://www.smlnj.org/doc/SMLNJ-C/index.html

so to the outside world your sml library would behave like a C library except with out the assiciated segfaults and memory leaks*

*not a guarantee

Projects popularize languages. Do the ground work for an interesting and undeniably 'cool' project using ML, and people will flock to the language. For instance,look at Erlang with ejabberd and mochiweb - both cool projects that have done wonders for a one-time-diamond-in-the-rough language like erlang (which is, btw, my development language of choice lately). I for one, would love to see somebody make something rad with ML, the language is a joy to think with.

There are several Standard ML compilers. The MLton wiki also contains a benchmark.

I used Moscow ML which compiles Standard ML into bytecode. It's not fast, but it works. MLton is often cited to be the best Standard ML compiler with regard to efficiency.

Note that Poly/ML version 5 or later supports both the traditional "heap dump" model, and C-style standalone executables. The documentation on the Poly/ML website is spread over many different spots, some of them with really old dates in the title -- but the system is alive and kicking.

The object-code generation is explained in passing in release notes for the version 5.0 release (we are presently at 5.5): see PolyML.export there.

There is also some Poly/ML C interface, which has been renovated as used for some GUI projects recently. You should ask at the polyml mailing list.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top