3 ms·
> Rust has already been ported to Emscripten (at least twice), but the code has not yet fully landed. This summer it’s happening though: Rust + Emscripten. Rust
by JasonSage 10y ago
> Rust has already been ported to Emscripten (at least twice), but the code has not yet fully landed. This summer it’s happening though: Rust + Emscripten. Rust on the Web. Rust everywhere.
I've been following the various RFCs and PRs for emscripten support for awhile now, and it's been cool to see some slow but steady progress. It's very nice to hear the Rust team acknowledge that they are actively moving towards making the web a first class target in the near future.
> Rust is uniquely-positioned to be the most powerful and usable wasm-targetting language for the immediate future. The same properties that make Rust so portable to real hardware makes it nearly trivial to port Rust to wasm.
As a web developer I couldn't be more excited to be using Rust right now. There's been a good amount of movement among JavaScript developers toward type systems and more explicit typing in JavaScript code. I find it's a much nicer development experience to have sane guarantees about the types in your JS code. I see Rust as the big next step for the web—a language that is still a pleasure to develop in, but with excellent static typing and tight, targeted builds without the bloat and buildup I'm accustomed to seeing with current transpile-to-JS strategies.
- kbenson 10y ago> There's been a good amount of movement among JavaScript developers toward type systems and more explicit typing in JavaScript code. > There's been a good amount of movement among JavaScript developers toward type systems and more explicit typing in JavaScript code. This is key to me. I'm not really interested in bolt-on additions or slight variations to JavaScript that leave me still grating against the edges of the language. Whether it's rust or something else, I want to use a language that's well designed, or at least consistent in the browser.
- nine_k 10y agoTry Elm or Purescript :)
- nathancahill 10y agoOne of the fundamental problems is that there isn't a "the browser".
- grayrest 10y ago> I see Rust as the big next step for the web—a language that is still a pleasure to develop in, but with excellent static typing and tight, targeted builds without the bloat and buildup I'm accustomed to seeing with current transpile-to-JS strategies. I think this will depend on the output size of the compiled file. I've always gotten very large js files out of emscripten, which are fine for games or media decoders, but would be undesirable for (e.g.) a vdom implementation that's part of a larger framework.
- mrec 10y agoAgreed. I'm moderately optimistic though - statically-linked Rust binaries have always tended to be on the chunky side, but AIUI a lot of that footprint is jemalloc, which I'd hope wouldn't be included in an Emscripten build.
- brson 10y agoBoth Rust and emscripten do produce notably large output. On the Rust side it's true that the emscripten port won't use jemalloc, but instead the emscripten malloc (which presumably is better tuned for its environment). Also the wasm format's main design goal is to reduce binary size.
- slimsag 10y agoWebAssembly will have a binary format with a 20-30% reduction size than its gzipped asm.js counterpart[1], for context :) [1] https://github.com/WebAssembly/design/blob/master/Rationale.md#why-a-binary-encoding https://github.com/WebAssembly/design/blob/master/Rationale....
- BinaryIdiot 10y ago> I see Rust as the big next step for the web—a language that is still a pleasure to develop in, but with excellent static typing and tight, targeted builds without the bloat and buildup I'm accustomed to seeing with current transpile-to-JS strategies. Maybe this will happen but it won't be through Emscripten. Emscripten is cool and all but it produces really poor code size-wise. Maybe if you lack JavaScript expertise you'll use this as a stop-gap but for a production system that needs scale I can't see it happening. Now maybe if it can be compiled into the Web Assembly intermedia? That seems like a good route to take.
- JasonSage 10y agoThat's addressed in the article. The LLVM backend is on the way and Rust will be able to take advantage of it relatively easily, it seems. Emscripten is more of an intermediate step to get Rust working on the web in the meantime—I doubt it's going to be the long-term solution for Rust on the web.