Live data from Hacker News

Learn WebAssembly by writing small programs

github.com

41–50 of 87 posts

Re: Learn WebAssembly by writing small programs

#41
post #20

Gave WASM a try and ran into problems exposing connections to a SQLite database I wanted to connect to locally. Has anyone done something like that before and can point to good resources?

Check out Spin! It includes sqlite support natively in the runtime since 1.4: https://www.fermyon.com/blog/spin-v14

Looks like it’s only available for Python, I was hoping for a more language agnostic solution. Thanks though!

Re: Learn WebAssembly by writing small programs

#42
post #20

Earlier quoted context omitted.

Check out Spin! It includes sqlite support natively in the runtime since 1.4: https://www.fermyon.com/blog/spin-v14

Looks like it’s only available for Python, I was hoping for a more language agnostic solution. Thanks though!

It is? The docs example shows support for Rust, TypeScript, and Python:

https://developer.fermyon.com/spin/sqlite-api-guide#using-sq...

I'm not sure what holds back from being a completely language agnostic solution, but I know when I tried binding functions into my Ruby app with wasmer I had nothing but problems, I wound up using WASI exclusively to communicate with my WASM modules. I don't honestly know how good the WASM language agnostic story is today. I gave a talk with my perspective as a Rubyist at OSS Summit and CDCon/GitOpsCon a few months ago in Vancouver. The talk (and lightning talk variant) are called "Exotic Runtime Targets: Ruby and Wasm on Kubernetes and GitOps Delivery Pipelines"

Re: Learn WebAssembly by writing small programs

#43
post #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... >

Thanks! That was fun. I hadn't seen it. There's the problem of bootstrapping METAL, but perhaps left for a different lecture! ;-)

Re: Learn WebAssembly by writing small programs

#44

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?

Is being a "JS killer" even a goal of WASM? From what I understand, WASM's goal is to allow computationally heavy workloads (e.g., image and audio processing) to the browser by providing a compilation target for C code. This is how we get nice things like Figma or MS Office running in the browser. Let WASM do the number crunching, let JS do the UI.

It's not the goal from what it seems. But it's definitely what would make it the most interesting to a lot of people, and it's what I think most people expected at some point.

For a lot of companies the only place JavaScript is ever used is on their website frontend. And it makes you wonder, why does it even still need to be JavaScript? With the rise of SPAs and the fall of normal document based websites, browsers are basically just becoming their own platform like Windows Desktop, Mac, Linux, Android, iOS, etc. You could say it's been that way for a long time, but more and more apps are becoming web based only because the browser is now powerful enough to run what used to be a desktop application.

Browsers are literally just a VM with an address bar. We go to a URL and run a program, except right now there's basically the limitation that the program has to be written at least partly in JavaScript. Being able to deploy an entire website as WASM is just the next logical step from what I see.

Re: Learn WebAssembly by writing small programs

#45
Looks very similar to the Exercism model, which also has a free WASM course filled with small exercises[1]. I wonder if the author considered contributing to that course or working together with them, it might get their work to a broader audience and leverage the existing toolset Exercism has to offer.

[1]https://exercism.org/tracks/wasm

Re: Learn WebAssembly by writing small programs

#46
post #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.

What makes hand written WASM too "low level"?

It isn't, really, what the Rust frameworks do is compile down to a specific interop, sure (JS + WASM, its not pure WASM due to lack of DOM access for starters).

That said, no reason a hand written WASM app isn't feasible, with appropriate JS glue

Re: Learn WebAssembly by writing small programs

#47
post #21

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?

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.

What would that change? DOM interaction can and is abstracted away by frameworks anyways and not performance critical

Re: Learn WebAssembly by writing small programs

#50
post #45

Looks very similar to the Exercism model, which also has a free WASM course filled with small exercises[1]. I wonder if the author considered contributing to that course or working together with them, it might get their work to a broader audience and leverage the existing toolset Exercism has to offer. [1] https://exercism.org/tracks/wasm

One thing I don't like about Exercism is that except for the most popular languages, the exercises are often not "sysematics".

In other words, it's just a bunch of leetcode-like questions, ordered by difficulties.

A proper course should order the exercises by language features. Exercism actually has built a fantastic interface for this[1], but not utiltized it for most langauges.

[1]: https://exercism.org/tracks/csharp/concepts

Post reply on HN