[1] https://github.com/JuliaLang/Microbenchmarks/blob/af3d18f7b3...
[2] https://github.com/JuliaLang/Microbenchmarks/blob/af3d18f7b3...
[1] https://github.com/JuliaLang/Microbenchmarks/blob/af3d18f7b3...
[2] https://github.com/JuliaLang/Microbenchmarks/blob/af3d18f7b3...
Most the speed advantage of the C here is due to reusing the same memory over and over, which you can do pretty easily in Julia as well. Here's the Julia code using in-place operations and it's still quite a bit more readable than the C version: https://gist.github.com/StefanKarpinski/e57f5a36b7890b261a0d.... I timed this and it's the same speed as the C version. When developing this, it follows the same general outline as the C version, but you have several benefits: (1) You can use asserts to compare to the easy version; (2) There are niceties like bounds checks and array indexing. In C you can't do (1) because there is on easy version to compare with. And doing the array index computations in C is kind of a nightmare—it's so easy to accidentally screw them up.