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.
way too many toFixed ... but that returns a string so then you still have to coerce it to a number. so inefficient and so much repetitive cruft that should be unnecessary in a properly designed language
the real problem is that the math operators actually return incorrect results .... it's not like anyone would do anything in js relating to money or that people would be angry about software being imprecise with their money
View all comments
Show parent comment
1
u/SasDerGrosse Jun 21 '18
Doesn't that mean JS is slower in math-related functions?
Sorry if I misunderstood, I'm just a beginner programmer.