Re:Deep JavaScript: Theory and Techniques
by jorangreef on Wednesday June 17, 2020 @05:40PM
(#23557103)
We actually wrote the original version in C with SIMD extensions as a Node.js binding, but the JavaScript version was still twice as fast. I kid you not. You will find the reason for this in the README, it's the last bullet point under "Fast": https://github.com/ronomon/hash-table#fast
Huh. Does that apply to WASM too or just to binding from Node?
Re:Deep JavaScript: Theory and Techniques
by jorangreef on Thursday June 18, 2020 @04:08AM
(#23560886)
I am not sure but I wouldn't think so, unless you have to serialize/deserialize or otherwise transform or inspect function call arguments in some or other way, as you need to do when binding JavaScript with C.
Re:Deep JavaScript: Theory and Techniques
by austincheney on Wednesday June 17, 2020 @05:34PM
(#23557057)
The algorithm for Array.sort is implementation specific, but there is an ECMAScript proposal for a standard algorithm.
Still, it's interesting that there is something to be gained under these circumstances. I'm typically skeptical of this sort of thing because the standard library is written in C++. One time I thought I was very clever and hand-wrote a more appropriate sorting algorithm for a specific use-case only to discover that, no, Array.sort() was still faster by sheer brute force.