In theory, yes, it would be slower for things that only need integers. In practice, there are so many other things that slow JS execution down so much more that this probably isn't a bottleneck worth worrying about.
If you're doing serious number-crunching, you don't use JS — you use something compiled to native code, possibly with the sticky parts written in hand-optimized assembler.
Not often, but it does happen. There are a rare few times when you know more about your code than you can explain to the compiler; there are a rare few times within that when that actually matters enough to bother with writing assembler.
Usually this isn't just for speed's sake when number-crunching. (That does happen, but only about once in a month's worth of blue moons.) The case I've most commonly seen is where you need to avoid a possible side-channel attack in your cryptography code — usually timing differences on different inputs — and so have to hand-write it in assembler to prevent dangerous optimizations while retaining the safer ones.
This is all library stuff, though. Application logic is basically only written in assembler if you're showing off.
View all comments
Show parent comment
6
u/once-and-again ☣️ Jun 21 '18
In theory, yes, it would be slower for things that only need integers. In practice, there are so many other things that slow JS execution down so much more that this probably isn't a bottleneck worth worrying about.
If you're doing serious number-crunching, you don't use JS — you use something compiled to native code, possibly with the sticky parts written in hand-optimized assembler.