4 ms·
A bit OT: what kind of performance do you normally expect from OCaml? I looked at the Prime Sieve challenge[1] recently and with the current submissions the Sta
by yakubin 5y ago
A bit OT: what kind of performance do you normally expect from OCaml? I looked at the Prime Sieve challenge[1] recently and with the current submissions the Standard ML solution is 3 times faster than the OCaml one. I've also spent some time optimizing this SML solution and got it several times faster still. With a bit more work I thinkg I could get it up to the speed of the fastest C solution. It's compiled with MLton. From that POV OCaml is a bit disappointing, since I've also viewed SML as a "hipster language" that hasn't had that much money put into it, while OCaml saw quite a bit more development, so I would expect the OCaml compiler to be able to produce better code. I've briefly looked at the OCaml code, but I don't know OCaml as much as SML, so can't really say what may be the issue in the OCaml case.
[1]: <https://plummerssoftwarellc.github.io/PrimeView/report?id=rbergen-1638510661.json&hi=False&hf=False&hp=False&fi=&fp=mt&fa=&ff=uf&fb=&tp=False&sc=pp&sd=True https://plummerssoftwarellc.github.io/PrimeView/report?id=rb...>
[2]: <https://github.com/PlummersSoftwareLLC/Primes https://github.com/PlummersSoftwareLLC/Primes>
- octachron 5y agoI would expect such a difference between OCaml and MLton (in either direction in fact) to be mostly the result of an apple-to-orange comparison. In this case, the OCaml code looks neither idiomatic nor optimized.
- naasking 5y agoMLTon is a whole program compiler, so it's not exactly comparable to OCaml. OCaml compiles insanely fast, MLTon not so much.