Nick Fitzgerald, a Rust and Mozilla engineer, writes about performance, allocators, garbage collection, WebAssembly and source maps.
HN commenters cite it for bump allocation and benchmarks, praise its graphical benchmark charts, and link its follow-up on speed without wizardry.
Another point where it’s doing something that to me as a Rust expert is obviously inferior: it’s using Unicode-aware string stuff although anything non-ASCII will either be ignored (if non-alphabetic) or panic (if alphabetic). It’d certainly be better to treat the input throughout the program as a sequence of bytes rather than as UTF-8.
This type of thing reminds me of the three articles ending in https://fitzgeraldnick.com/2018/02/26/speed-without-wizardry.html (which has links to the first two parts of the saga), where one guy rewrote stuff in Rust for performance, another demonstrated how it was possible to make the JavaScript version faster than the Rust by some algorithm changes and by various painful and fragile tricks requiring detailed knowledge of the runtime environment, and finally the first guy applied the applicable parts of that back to the Rust, after which it handily beat the JavaScript again while also being more consistent and dependable.
Pretty much, yeah. Today's web applications go through multiple forms of compilation and transformation. Conversion from ES6 modules to CommonJS, compilation of newer JS syntax into equivalent older syntax supported by more browsers, minification that renames symbols to cut down on the total byte size delivered, and bundling of hundreds of individual modules into a single output JS bundle (or possibly several code-split bundles). Because of that, debugging the delivered source as-is isn't feasible. Sourcemaps allow the browser's devtools to display the original source, and a developer can debug the code as it was before any compilation steps were applied.
I saw a post a couple years back that suggested that DWARF debugging symbols could be used as an inspiration for improving sourcemaps: http://fitzgeraldnick.com/2015/06/19/source-maps-are-insufficient.html .
Thank you!
TLDR: JSX transformer makes the following ES6 features compatible with old browsers (IE8+)
* arrow functions [http://tc39wiki.calculist.org/es6/arrow-functions/]
* classes [https://github.com/esnext/es6-class]
* destructuring [http://fitzgeraldnick.com/weblog/50/]
* object concise methods [http://ariya.ofilabs.com/2013/03/es6-and-method-definitions.html]
* rest parameters [http://tc39wiki.calculist.org/es6/rest-parameters/]
* template strings [http://tc39wiki.calculist.org/es6/template-strings/]
* object literal property shorthand [http://tc39wiki.calculist.org/es6/object-literal-enhancements/]
Notably absent: default parameter values and block scoping ("let")
There was a back and forth on that subject a few years back: Mozilla rewrote their sourcemap parser from JS to naïve Rust (/WASM) for a 5.89x gain, mraleph objected to the need and went through an epic bout of algorithmic and micro-optimisations to get the pure JS to a similar level, then the algorithmic optimisations were reimported into the Rust version for 3x further gain (and much lower variance than the pure JS).
https://hacks.mozilla.org/2018/01/oxidizing-source-maps-with-rust-and-webassembly/
https://mrale.ph/blog/2018/02/03/maybe-you-dont-need-rust-to-speed-up-your-js.html
https://fitzgeraldnick.com/2018/02/26/speed-without-wizardry.html
To save some searching, the three referenced articles seem to be:
- Oxidising Source Maps with Rust and WebAssembly: https://hacks.mozilla.org/2018/01/oxidizing-source-maps-with-rust-and-webassembly/
- Maybe you don’t need Rust and WASM to speed up JS: https://mrale.ph/blog/2018/02/03/maybe-you-dont-need-rust-to-speed-up-your-js.html
- Speed Without Wizardry: https://fitzgeraldnick.com/2018/02/26/speed-without-wizardry.html
So, in general, Rust should be good for writing VMs. If you want a JIT, though, Rust may not have any super huge advantage with it, specifically, as it would basically be all unsafe anyway.
There was a really great blog post about writing a Scheme implementation, including a GC: http://fitzgeraldnick.com/weblog/60/