5 ms·
Rust+WebAssembly is excellent.
by bugmen0t 8y ago
Rust+WebAssembly is excellent.
- topbanana 8y agoI'm sure I'm missing something. The beauty of Rust is you can operate at the baremetal level in safety. It's not the most productive language to work with. So why target WebAssembly from it?
- bluejekyll 8y agoSome of us find the language highly productive, and extremely accurate in its usage in many different spaces. In terms of webassembly, there is a sweet spot for Rust, which is in speeding up CPU bound JS routines. There is a project, wasm-bindgen, to make building these high performance pieces and injecting them into JS easy. Some of us even want to see it grow as an alternative language for full web development. There are a few projects that aim to make this easy (compiling to wasm): stdweb, cargo-web, js-sys. It’s already a fully capable language capable of targeting the web. The features you get for this that many of us appreciate: no garbage collector (ie bounded memory usage), strict error checking, strongly typed null checks, an amazing type system, etc. Productivity means different things to different people.
- acdha 8y agoHere's an example: I wanted to have decent hashing performance in JavaScript (large file uploads protected against bitrot). There are a hodgepodge of different JavaScript libraries with inconsistent algorithm support and performance characteristics; SubtleCrypto is becoming more standard but has limited algorithm support and doesn't support efficient operations on large inputs. With https://github.com/acdha/wasm-hashing https://github.com/acdha/wasm-hashing I was able to use the high-quality Rust hashing system to support all of the different algorithms I needed with a consistent interface and performance was actually competitive with or better than the browsers' native SubtleCrypto implementation. That's a really nice capability to have in your back pocket, especially since it comes with Rust's usual assistance for code-quality.
- steveklabnik 8y agoThat’s very cool! Is there a reason you’re using wasm-bindgen directly instead of using wasm-pack?
- acdha 8y agoWhen I started wasm-pack was still moving pretty rapidly and it took a lot longer to do builds when I was working interactively. Now that the split went through I've been meaning to revisit that.
- steveklabnik 8y agoAh, cool :) if it goes poorly, I’m sure the team would love to know!
- acdha 8y agoThey've posted a lot of interesting updates since I last worked on that. Might be time to dust that project off.