ClojureScript and optimized C [video]
youtube.com
youtube.com
marcel@sarek[tmp]cc -Os sumints.c && ./a.out
49999995000000
Elapsed time: 0.000031 millis
The original: marcel@sarek[tmp]cc -Os orig.c && ./a.out
49999995000000
Elapsed time: 8.276664 millis
That's a factor 266989 difference, if anyone cares :)The code in question:
(apply + (range 1e7))
is just summing a bunch of numbers. That's it. It's very easy to optimize for the sake of benchmarks.It's way too trivial to use for any kind of meaningful real-world comparison.
I can tell you that the answer is definitely no, in my tests V8 being slower than the JVM by a factor ranging between 4 and 10.
If you're interested in seeing that in action, you can download the library's source code and run its tests for the JVM and see how that feels in comparison with the same tests being executed for JS. See: https://github.com/monix/monix
[PS: Next time remember to submit the youtube.com version instead of the youtu.be, because youtu.be is autokilled.]
https://gist.github.com/sfermigier/9f60f01d1b4e8508a3a56bc42...
Any idea why ?
In seriousness -- does this behaviour persist if you drop the computation into a `for` loop for a number of iterations instead of calling it manually every time?