3 ms·
Does anyone know how fast MLton (whole-program optimization) programs run in comparison to other languages?
by platz 7y ago
Does anyone know how fast MLton (whole-program optimization) programs run in comparison to other languages?
- scns 7y agoFaster than C years ago, nowadays it may be different because of all the optimization work put into C compilers. Long compile times though.
- rscho 7y agohttp://www.ffconsultancy.com/languages/ray_tracer/index.html http://www.ffconsultancy.com/languages/ray_tracer/index.html
- cannam 7y agoObviously depends on what you're doing, but in my experience it generally isn't as fast as the C++ I write and compile with a modern compiler. Maybe comparable with other optimised compiled languages with GC. It's not magically fast, but it is quite good at avoiding unexpected slow cases - which can help it "win" even against C++ sometimes. I generally test with MLton and Poly/ML, and MLton does not always produce faster executables, though most of the time it does. Poly/ML is a good compiler as well, and it has much faster compile times.
- platz 7y agoI assume there is a lot of pointer indirection as is the norm in FP languages that hurts performance quite a bit
- cannam 7y agoYep, I guess it doesn't quite reflect the modern reality for memory and cache access there - although at least primitive types are unboxed, inlined in arrays and records, and represented as machine types. There are probably more opportunities to do that in a whole-program compiler, which doesn't need to carry type information between modules. I believe it also doesn't do SIMD auto-vectorization, which is a recent improvement in C++ compilers that's made a difference to some of my own code.
- tsuyoshi 7y agoWhen I converted a CPU-intensive program from OCaml to MLton-compiled SML, without changing any of the algorithms, I got a 30% speedup. That was more than 10 years ago though, and both compilers have seen some improvement since.
- c-cube 7y agoOCaml now has flambda, which is a significant improvement on its baseline optimizer. I think the difference wouldn't be that wide today :)
- hajile 7y agoIt's about as fast as golang. It won't match the speed of a non-GC'd languages like C/C++/Rust (not that I'd expect any different).