Live data from Hacker News

Rust and WebAssembly in 2019

fitzgeraldnick.com

21–30 of 97 posts

Re: Rust and WebAssembly in 2019

#21

Earlier quoted context omitted.

We could add support for and not need JS to load it. Once the host bindings are implemented that would be a good fit.

Maybe! There’s not really much demand for such a thing. Web platform people don’t have the disdain for JS that many internet commenters do.

I don't disagree with that :) But it would be an interesting experiment to build a JS-free web runtime and see how/if we could get more predictable resource usage this way.

Re: Rust and WebAssembly in 2019

#22

Earlier quoted context omitted.

Maybe! There’s not really much demand for such a thing. Web platform people don’t have the disdain for JS that many internet commenters do.

I don't disagree with that :) But it would be an interesting experiment to build a JS-free web runtime and see how/if we could get more predictable resource usage this way.

cough dart cough

Re: Rust and WebAssembly in 2019

#23

Earlier quoted context omitted.

We could add support for and not need JS to load it. Once the host bindings are implemented that would be a good fit.

Maybe! There’s not really much demand for such a thing. Web platform people don’t have the disdain for JS that many internet commenters do.

I think this sort of thing is always a bigger deal than it seems. I think most people are actually really averse to learning new platforms, and things that enable people to make stuff without having to learn a different platform are way more popular than I would expect.

Examples: phonegap, electron, unity, love2d, reactnative, and nodejs itself. (Node = I know web but not native, can you help me write server code without learning C/python).

Most of this stuff solves the problem of “I want to program on platform X, but I’m most comfortable in Y. Can someone prevent me from needing to learn X’s paradigms?”. Arguably that’s one of the biggest draws of wasm itself, and why the communities around a lot of languages are excited about it. (Eg rust, blazer). (“Ugh don’t make me learn JavaScript. I already know C# and I like it. Can I just do that instead?”)

To your point, I think it seems like there’s not much demand for such a thing because the people it would help aren’t involved enough yet to file issues. If they’re invested enough in the community and the problem, they’re probably invested enough to learn enough JS to bridge the languages themself anyway.

Which is all to say, I think making a wasm script tag after host bindings are in is a good idea and will make a lot more people happy than it would seem if you just surveyed the existing community.

Re: Rust and WebAssembly in 2019

#24
post #23

Earlier quoted context omitted.

Maybe! There’s not really much demand for such a thing. Web platform people don’t have the disdain for JS that many internet commenters do.

I think this sort of thing is always a bigger deal than it seems. I think most people are actually really averse to learning new platforms, and things that enable people to make stuff without having to learn a different platform are way more popular than I would expect. Examples: phonegap, electron, unity, love2d, reactnative, and nodejs itself. (Node = I know web but not native, can you help me write server code wit…

Eh, I think that the few lines of JS it takes to instaniate a wasm module isn’t a problem even for people who aren’t great at JS. I’m one of those people, and it’s only a few lines, really. It can even be generated by tools. It’s just not that big a deal.

Re: Rust and WebAssembly in 2019

#25

Figma uses WASM and some claim that it's even faster than natively implemented Sketch. I am surprised that now it's possible to make a web app as fast as native app. Is Visual Studio Code using WASM?

> faster than natively implemented

It still depends on your implementation. The same code will take about 1.2x as long to execute in wasm (of course this means that a slightly faster implementation can be faster over all).

> Is Visual Studio Code using WASM?

I have read on HN that they use Rust for some internals, but so far I haven't been able to confirm it. It would make sense for things like intellisense to be compiled, but don't forget that with Electron you can still access the platform with all iits capabilities, so you wouldn't need wasm.

Re: Rust and WebAssembly in 2019

#26
post #15

It didn't click until just now that rust is very naturally suited to WebAssembly due to its lack of garbage collection. As I understand it, there's no current plans for WebAssembly to include a garbage collector, so higher level languages that want to compile to it will need to bundle their own, increasing the size of the download quite a bit.

> As I understand it, there's no current plans for WebAssembly to include a garbage collector There are plans to add a garbage collector. See https://hacks.mozilla.org/2018/10/webassemblys-post-mvp-futu... . But meanwhile, Webassembly is mainly just for C and Rust.

> Webassembly is mainly just for C and Rust

That's absolutely incorrect. Go and .NET can target WASM for quite a while now.

Microsoft's Blazor is specially interesting. Their FlightFinder demo written in pure C# renders a beautiful app: https://i.imgur.com/HHFkB1E.png

Code here: https://github.com/aspnet/samples/tree/master/samples/aspnet...

Re: Rust and WebAssembly in 2019

#27

Figma uses WASM and some claim that it's even faster than natively implemented Sketch. I am surprised that now it's possible to make a web app as fast as native app. Is Visual Studio Code using WASM?

> faster than natively implemented It still depends on your implementation. The same code will take about 1.2x as long to execute in wasm (of course this means that a slightly faster implementation can be faster over all). > Is Visual Studio Code using WASM? I have read on HN that they use Rust for some internals, but so far I haven't been able to confirm it. It would make sense for things like intellisense to be com…

> I have read on HN that they use Rust for some internals

I know the multi-file search is done via ripgrep, which is written in rust. But it's not compiled to wasm.

Re: Rust and WebAssembly in 2019

#28
post #15

It didn't click until just now that rust is very naturally suited to WebAssembly due to its lack of garbage collection. As I understand it, there's no current plans for WebAssembly to include a garbage collector, so higher level languages that want to compile to it will need to bundle their own, increasing the size of the download quite a bit.

> As I understand it, there's no current plans for WebAssembly to include a garbage collector There are plans to add a garbage collector. See https://hacks.mozilla.org/2018/10/webassemblys-post-mvp-futu... . But meanwhile, Webassembly is mainly just for C and Rust.

The "problem" with integrating with the host gc is that it means language who have subtly different approaches to garbage collection can't trust compiled code behavior to be identical in the browser.

This is probably not a terrible thing, since a native garbage collector in WASM (unless it was designed in an extremely simplistic, low-level form) would also probably not be suitable for the diversity of the languages that want to include one.

It is (probably) better for individual languages to write their own, even if that increases binary sizes.

Re: Rust and WebAssembly in 2019

#29
post #23

Earlier quoted context omitted.

I think this sort of thing is always a bigger deal than it seems. I think most people are actually really averse to learning new platforms, and things that enable people to make stuff without having to learn a different platform are way more popular than I would expect. Examples: phonegap, electron, unity, love2d, reactnative, and nodejs itself. (Node = I know web but not native, can you help me write server code wit…

Eh, I think that the few lines of JS it takes to instaniate a wasm module isn’t a problem even for people who aren’t great at JS. I’m one of those people, and it’s only a few lines, really. It can even be generated by tools. It’s just not that big a deal.

the big deal is not knowing the platform and therefore reproducing it in wasm. a simple example is most games compling in libjpg, libpng, zlib when the browser already has that stuff built in.

Re: Rust and WebAssembly in 2019

#30

It didn't click until just now that rust is very naturally suited to WebAssembly due to its lack of garbage collection. As I understand it, there's no current plans for WebAssembly to include a garbage collector, so higher level languages that want to compile to it will need to bundle their own, increasing the size of the download quite a bit.

Yep! This is a key insight. Even beyond that, there are two approaches you can take: writing your app in wasm, or writing libraries in wasm. Languages with larger runtimes may work for apps, but you don’t want to use them for libraries, because then you lug around every runtime for every language used. Even once wasm can integrate with the host’s GC, non-GC’d languages will have a place in implementing core libraries…

This only applies to libraries served from separate locations though, right? No issue writing a Haskell library for wasm and then having consumers compile their app leveraging your library (at which point it's bundled with the RTS)
Post reply on HN