3 ms·
Go has to embed it's runtime and GC into builds, so build size and performance will take a hit here. Same goes for most popular languages. For me Rust offers t
by the_duke 6y ago
Go has to embed it's runtime and GC into builds, so build size and performance will take a hit here. Same goes for most popular languages.
For me Rust offers the best WASM experience and tooling at the moment.
Rust has no GC and (almost) no runtime.
It also has official wasm build target support out of the box, including generating Typescript definitions for Rust types.
The ecosystem is somewhat well-developed:
* wasm-bindgen for general interop in both directions
* js-sys / web-sys for (low-level) type-safe and surprisingly efficient browser API bindings
* wasm-bindgen-futures for easy Promise <-> Future interop
* wasm-pack for easy building
* ...
Getting the code size low is still a challenge though.
A Rust implementation of the Krausest frontend framework benchmark takes a top 4 spot [1]. Despite this benchmark not favouring wasm at all since it requires little computation and mostly does FFI calls.
(ps: C++ is in a decent state as well)
[1] https://rawgit.com/krausest/js-framework-benchmark/master/webdriver-ts-results/table.html https://rawgit.com/krausest/js-framework-benchmark/master/we...
- pjmlp 6y agoIt is still much smaller than most SPA used to display static text.
- amelius 6y ago> Go has to embed it's runtime and GC into builds, so build size and performance will take a hit here I expect that WASM doesn't have the concurrency model required by a modern concurrent garbage collector like Go's, but perhaps I'm wrong.
- foota 6y agoIt's likely much slower, but it should be able to run just fine single threaded as well.
- pansa2 6y ago> C++ is in a decent state as well I’d still choose Go or Rust over C++, though, because they’re memory-safe. This recent discussion shows that’s still important in the context of WebAssembly: https://news.ycombinator.com/item?id=24216764 https://news.ycombinator.com/item?id=24216764
- the_duke 6y agoSure, for new projects I choose Rust over C++ whenever feasible. But a huge amount of the worlds software is written in C++, and will remain so for decades. Getting some of that code to run well in WASM can be a big win for certain domains.
- stjohnswarts 6y agoModern C++ has a lot of memory safe operations if you use them (smart pointers, atomics, actually using RAII properly and universally), although I'm not sure how much overhead they might add to a wasm blob. Rust seems almost perfect for it though, but no reason to discourage C++ people; it can be a relatively modern language if you let it.
- pjmlp 6y agoAs someone that loves still having C++ on the toolbox, that is unfortunately only true if you have 100% control over the source code and have all team on modern C++ mindset.