5 ms·
No, OCaml and Haskell can be faster than C at times. Look at some benchmarks.
by gleenn 14y ago
No, OCaml and Haskell can be faster than C at times. Look at some benchmarks.
- maximilianburke 14y agoCan you point the way to some of these benchmarks?
- wreckimnaked 14y agofor instance: http://shootout.alioth.debian.org/u32/performance.php?test=chameneosredux http://shootout.alioth.debian.org/u32/performance.php?test=c... needless to say that all benchmarks will be very biased, as idiomatic code is not necessarily the most optimized one.
- igouy 14y agobiased: "showing an unreasonable preference or dislike based on personal opinion". http://dictionary.cambridge.org/dictionary/american-english/biased?q=biased http://dictionary.cambridge.org/dictionary/american-english/... Can you show that the benchmarks game is as-you-say biased?
- wreckimnaked 14y agoYou're right, point taken, I clearly misused the word; it has nothing to do with any personal opinion. I was using 'biased' thinking about its meaning on the Machine Learning context [1]. My intention was to state that idiomatic code is not necessarily the most performant one, and that the codes used in the benchmarks game may contain some not very idiomatic optimization codes [2]. That said, it tends to evaluate the implementation of a certain compiler, and not exactly how the constructs and concepts of those languages result on the measured performance. 1: http://en.wikipedia.org/wiki/Inductive_bias http://en.wikipedia.org/wiki/Inductive_bias 2: http://shootout.alioth.debian.org/u32/benchmark.php?test=chameneosredux&lang=python3 http://shootout.alioth.debian.org/u32/benchmark.php?test=cha...
- postfuturist 14y agoI did a benchmark. Naive Haskell implementation took 28 seconds, heavily optimized / hinted Haskell version took 11 seconds. Naive C implementation took 0.3 seconds. https://github.com/deliciousrobots/sml_life https://github.com/deliciousrobots/sml_life
- mej10 14y agoI replaced the array/"surrounding" list with an unboxed vector, and removed the strictness annotations and it runs at ~0.85 on my machine, while the C code runs at around ~0.5. The code is so incredibly close to your SML code (where you also spell out that you are using the Vector type). I am just blown away by how matter of fact you were in your statement. Please either change your benchmark to use the same data type as all of the other examples, or stop using it as an example of Haskell's performance.
- postfuturist 14y agopull request? I'm no Haskell expert (which apparently you need to be to get decent performance.)
- mej10 14y agoMy point is, I am not Haskell expert, but I know that linked lists aren't an efficient data structure for what we're doing. You didn't use lists in your other implementations, so it was just weird that you did for Haskell (originally, and then sort of again for life-array.hs). For your life-array.hs implementation, you replaced the Grid with an array, but not the "surroundings" with one, even though you used Vector for both in your SML implementation. Built with -O2 option: https://gist.github.com/3189306 https://gist.github.com/3189306 Sorry if I came off a bit assholish. People have been saying that you need to be a Haskell expert to get good performance forever, and in my experience this just isn't true. I will admit that there is clearly a problem with how things are introduced, as it is common that new Haskellers think they can use lists for every thing. I am sure part of the problem is that this is one of the few data structures available from the Prelude.