4 ms·
I don't believe this, but it's an understandable error. First, let me be clear that handwritten optimized WASM is faster and smaller than heavily optimized Jav
by Veedrac 8y ago
I don't believe this, but it's an understandable error.
First, let me be clear that handwritten optimized WASM is faster and smaller than heavily optimized Javascript on primitive types, by significant margins. It doesn't surprise me that compilers burn this (to put it mildly, compilers aren't great at code generation), but it's worth noting that the raw throughput difference is there and definitely measurable. This difference should be expected to grow in the near future, since browsers' WASM compilers are suboptimal right now.
Now, more importantly, the major criticism I have with this is that it is presumably focused on small imperative tasks, which ignores the main places performance is lost in a language like Javascript:
1. Javascript can't handle memory efficiently without doing everything through typed arrays. Efficient use of memory (compact representations, mutation and sharing, sequential access, etc.) is an unreasonable task in a high level language, whereas transpiling to WASM works.
2. Javascript's abstractions are heavy and inefficient. Building your own abstractions is liable to have similar issues. A language like C, C++, or Rust lets you build efficient abstractions both in the small ("zero-cost abstractions") and in the large (architecturally).
Little unpublished demos won't show that.
- imtringued 8y agoWASM is basically the formalisation of asm.js. Therefore writing javascript code that rivals WASM is possible by definition but writing fast Rust/C++ code is much easier than trying to do the same with javascript (it won't look like javascript).
- Veedrac 8y agoasm.js is not "just" efficient Javascript though. It is typically compiled a different way to standard JS.
- jbergens 8y agoNot that I disagree with you but we might need to have more discussions about what is a common/normal app. How large is it in kb, in lines of code, in nbr of functions or classes? How large and how many data structures is it normally using? Without this it is hard to say if any language will help. WASM is probably faster and if cross language calls don't cost anything extra (Firefox seems have solved most of this) a combination of WASM and js shouldn't be slower than a pure js solution but if the applications isn't _that_ large and doesn't use too many data structures it might not be much faster either.