Live data from Hacker News

Learn WebAssembly by writing small programs

github.com

21–30 of 87 posts

Re: Learn WebAssembly by writing small programs

#21

Pretty cool. I haven't really explored WASM hands-on (I'll give this guide a try) but, given that it's already been a few years, I think it's been hugely beneficial for web development. Not the "JavaScript killer" some where hoping for, though it was never meant to be one. Instead it integrates pretty nicely within the existing ecosystem, optimizing existing use-cases and allowing new ones when heavy computations are…

I've been watching WASM from afar, and it's my understanding that it's not a JS killer because it doesn't have direct access to the DOM or to most DOM APIs. I'm curious if there's another reason I'm missing?

Yep. Give access to the DOM - perhaps via a batch update/fragment mechanism and watch as it becomes a JS killer. But WASM is currently a starved prisoner locked up in a room only allowed to view the goodies outside the cell door.

Re: Learn WebAssembly by writing small programs

#22

Is there a WA UI framework for web similar to Svelte or Vue?

Hand written wasm is too low level to use a UI framework with, but there are rust frameworks that compile to wasm for web. For example, Yew and Leptos are both web-first frameworks, and there are a few such as Dioxus or wgpu that are native-first and work on web.

Re: Learn WebAssembly by writing small programs

#25
post #16
post #11

This is great, thanks! One of my favorite ways to learn a new language or framework is via "koans"[1], which this reminds me of. It's a gentle ramp up from basic to advanced features, and the TDD-like workflow of seeing a test fail, understanding why, and fixing it, is really conducive to learning, while giving you that dopamine jolt from "a-ha!". [1]: https://github.com/ahmdrefat/awesome-koans/blob/master/koans...

sounds like a great way to learn a language "on your own". unfortunately, Rust is missing. can anyone propose a link?

Isn't that basically Rustlings?

Re: Learn WebAssembly by writing small programs

#26
post #25
post #16

Earlier quoted context omitted.

sounds like a great way to learn a language "on your own". unfortunately, Rust is missing. can anyone propose a link?

Isn't that basically Rustlings?

i think you've found what i'm looking for! https://github.com/rust-lang/rustlings

Re: Learn WebAssembly by writing small programs

#28
post #17

Earlier quoted context omitted.

It doesn't have access to _anything_ (in the browser, in other runtimes there is WASI with POSIX functions). Everything has to be imported from or exported to JS. And currently using anything but C, C++ or Rust isn't feasible, as the runtime needed for a GC is way too big. A Haskell "Hello World" for example is about 1MB (even after running `wasm-opt` on the generated WASM binary).

> isn't feasible This is kind of subjective, and in the context of "is this a JS killer" which is what you're answering, I'd agree, it makes sending the Wasm to the browser a bit of a non-starter that it requires a large bundle most of which is simply boilerplate for whatever runtime, without some type of local storage and persistent cache it's difficult to imagine using Ruby in a Wasm for example. If you're deployin…

Well, the main reason why I'm taking a deeper look at WASM is because I'm creating a language and compiler that is optimized to compile to WASM. While I don't think that my compiler will be the JS killer, I do think that WASM languages using a (the WASM) GC have a future.

Re: Learn WebAssembly by writing small programs

#29

Earlier quoted context omitted.

I've been watching WASM from afar, and it's my understanding that it's not a JS killer because it doesn't have direct access to the DOM or to most DOM APIs. I'm curious if there's another reason I'm missing?

It doesn't have access to _anything_ (in the browser, in other runtimes there is WASI with POSIX functions). Everything has to be imported from or exported to JS. And currently using anything but C, C++ or Rust isn't feasible, as the runtime needed for a GC is way too big. A Haskell "Hello World" for example is about 1MB (even after running `wasm-opt` on the generated WASM binary).

Virgil compiles to Wasm and brings its own GC as well, and the runtime is on the order of about 4KB. The GC is a simple semi-space copying collector and the compiler prunes away dead code from libraries, so binaries are pretty small. So overall I don't think this is a Wasm issue as it is mostly a language runtime size issue.

Re: Learn WebAssembly by writing small programs

#30

Is it just me, or does "WebAssembly" seem like an oxymoron? Maybe it's because I've been involved with the web since its earliest beginnings.

You might like this bit of speculative history: https://www.destroyallsoftware.com/talks/the-birth-and-death...>
Post reply on HN