From my experience of cross-compiling C/C++, yes, most asm.js / wasm code will be faster than most handwritten Javascript code, sometimes dramatically faster because:
- asm.js / wasm has fixed and very simple types, a variable will never change its type and there are no JS ‘objects’
- there is no garbage collection taking place since there are no objects to be garbage collected, the only exception is when the boundary to JS needs to be crossed to call into HTML5 APIs
- most browsers detect asm.js now and take various shortcuts, for instance on Firefox, asm.js is AOT compiled so that the code doesn’t need to ‘warm up’ first
Handwritten Javascript is still better for simple webpage tasks or manipulating the DOM though, also C++ tends to create code bloat if not careful and the resulting asm.js / wasm blobs can be shockingly big as a result. I think the same will apply to Rust, you’ll have to avoid some patterns and techniques to keep compiled size down. I wrote a blog post about this a short while ago (this is about C++, but as I said, I think Rust will also require to be careful):
http://floooh.github.io/2016/08/27/asmjs-diet.html
I am really, really excited to see Rust supporting asm.js/wasm
Cheers,
-Floh.