HNHacker News
TopNewBestAskShowJobs

benno128

285 karma · joined June 19, 2021

submissionscomments
benno128··on Show HN: I built a WASI playground for running CLI binaries in the browser
I don't really know much about the component model, sorry!
benno128··on Show HN: I built a WASI playground for running CLI binaries in the browser
Good idea! It's a bit harder, but totally doable.
benno128··on Show HN: I built a WASI playground for running CLI binaries in the browser
Oh awesome!! I've just added Trealla to my issues list to add it to Runno.

If you go into settings you can switch stdin echo on/off. I have stdio devices set up to return their file type as "Character Device" (see: https://github.com/taybenlor/runno/blob/main/packages/wasi-m...). It seems like some binaries handle this well and act like they are directly connected to the TTY (e.g. my quickjs example). Not sure how they determine that. I'm very much coming at this from a web-developer interested in WASI direction, and not from any experience with OSes or linux.

Edit: btw my WASI runtime (@runno/wasi-motor) is very much in "I haven't even released it as an NPM package" state but you're welcome to copy the code and use it https://github.com/taybenlor/runno/tree/main/packages/wasi-m...

benno128··on Show HN: I built a WASI playground for running CLI binaries in the browser
It’s really cool stuff, hey! Early days but really interesting applications in serverless so far.
benno128··on Show HN: I built a WASI playground for running CLI binaries in the browser
Good spotto! That's an old WASI runtime from wasmerjs (https://github.com/wasmerio/wasmer-js).

That's not the WASI runtime being used in this playground. The one in this playground is @runno/wasi-motor (https://github.com/taybenlor/runno/tree/main/packages/wasi-m...). I haven't released it as an NPM package, but it's all MIT so feel free to copy it.

benno128··on Show HN: I built a WASI playground for running CLI binaries in the browser
I've also put up an article with a walkthrough of how to use the playground to run FFmpeg: https://runno.dev/articles/ffmpeg
benno128··on Show HN: I built a WASI playground for running CLI binaries in the browser
Yeah the documentation is rather lacking and hard to understand. The best place to start is here: https://wasi.dev/
benno128··on Show HN: I built a WASI playground for running CLI binaries in the browser
Yeah absolutely. Webassembly.sh was a big inspiration for my original build for Runno (https://runno.dev). The `prompt` issue is caused by code-rot, it used to work but then stopped working after browsers standardised a workaround for Spectre vulnerabilities in `SharedArrayBuffer`. Runno uses some neat tricks to get around this even when `SharedArrayBuffer` isn't available.

Part of the reason I started working on this playground was because I felt like the Wasmer WASI runner didn't work in the ways I wanted it to. Having a full end-to-end understanding of my WASI implementation has really helped, and I'm looking forward to moving Runno over to my new WASI runtime.

benno128··on Show HN: I built a WASI playground for running CLI binaries in the browser
memfs is very cool, but the WASI runner in this demo doesn't use it. I implemented my own virtual filesystem (see: https://github.com/taybenlor/runno/blob/main/packages/wasi-m...).

Will look at the FS spec. I would hope that it would be shaped in a way that makes sense for WASI (brief look seems like it is). I'd also love it to be something that makes sense from the JavaScript side as well.

benno128··on Show HN: I built a WASI playground for running CLI binaries in the browser
Thanks!

What's super neat here is that I didn't have to build that. The WASI standard defines `fd_fdstat_get` which tells the binary the type of the file descriptor. For stdin/stdout/stderr I return that it is a "Character Device" (https://github.com/taybenlor/runno/blob/main/packages/wasi-m...). QuickJS understands that means it's running in a TTY and so it emits all the right characters to do colouring. XTerm.JS then interprets those characters and displays the appropriate colours.

benno128··on Show HN: I built a WASI playground for running CLI binaries in the browser
G'day! It's a bit hard to understand what this is, because there's a lot of other stuff in the space. What I've written here is a WASI runner for the browser. I've also hooked up a terminal and virtual FS to it. WASI (WebAssembly System Interface) is a standard aimed at writing portable WebAssembly binaries that can run on servers, embedded devices, or locally on your computer. It's not really aimed at the browser. I went through and implemented the whole standard in TypeScript - then built this interface around that implementation so I could play with it.

One really neat thing here is how easy it is to write Rust that targets WASI. If you're into Rust, I'd recommend looking at the source of the demos and then trying out your own WASI binaries.

Here to answer questions if anyone has any!

benno128··on The mystery of social behavior in octopuses
There are some vegans and vegetarians who subscribe to a "no pain" version of this which allows eating creatures like oysters who verifiably can't feel pain.
benno128··on CPython's main branch running in the browser with WebAssembly
It's part of the Atomics feature set (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...). You have a shared chunk of memory and you say "please sleep until this memory changes". Then it's up to the host to change that memory.
benno128··on CPython's main branch running in the browser with WebAssembly
There's a version of CPython 3.6 compiled here (https://wapm.io/package/python) which is ~5mb gzipped.
benno128··on CPython's main branch running in the browser with WebAssembly
In WebAssembly.sh (https://github.com/wasmerio/webassembly.sh) they run WASM binaries in a Web Worker and then use `SharedArrayBuffer` to block the WebWorker while the main thread does some work (e.g. collect input). You could use a similar solution.

When building Runno (https://runno.dev) I forked off that project and did a bunch of other things on top to get blocking to work in Safari and non-cross-origin-isolated contexts.

Ultimately I think it's JavaScript's (or whichever host language) responsibility to block when the binary calls out (if that is the expected semantics).

benno128··on Show HN: Open-source web embeddable code runner
I'm not super familiar with webassembly.studio but it does look like you could use runno to implement something like that. You'd want to look at the Host API to start with if you wanted to build a proof of concept.
benno128··on Show HN: Open-source web embeddable code runner
Thanks Syrus! The stuff you're all building at Wasmer has been really useful (and is super cool).
benno128··on Show HN: Open-source web embeddable code runner
Yeah I love the use case of documentation! Right now Runno wouldn't be great for libraries (or web requests!) but it's definitely something I'd like to support.

I guess it would depend on the browser. There's two different fallbacks for the IO. So if the env doesn't support SharedArrayBuffer it will fallback to using a ServiceWorker hack. If that's not supported it will fallback to using an input prompt. But if the browser doesn't support WebAssembly there's no fallback mechanism.

PS: Thanks!

benno128··on Show HN: Open-source web embeddable code runner
G'day! A year or so ago I was playing around with building an online Introduction to Python course, but I got distracted by this problem that seemed like it should be solved: how can I embed runnable snippets on the web?

There’s a bunch of closed-source solutions that rely on other services. I was hoping for a way to just install a package, and then run code. Especially small snippets like print, input and if statements.

So I started building Runno. It lets you embed snippets of code from a few different languages (Python, JavaScript, C, C++ and SQL currently) within your website and runs it all client side using Web Assembly. You can use it without any packages using an iframe, or install the npm package and use it as a Web Component.

Happy to answer any questions you have about it!

benno128··on Meat and mental health: Meat eaters suffer less depression, anxiety
This reminds me of the research on alcohol being good for heart disease. Excerpt from Science Vs:

> Eric found that drinking booze… lowered the men’s risk of a heart attack as much as exercising regularly… Which is bonkers!

> So Kaye’s like: ok… all these studies are showing that those who drink have less heart disease than those who don’t… well have you ever thought… who are these non-drinkers in these studies? Like… what kind of person doesn’t drink anything?

> She started looking into the studies that had been done on people who don’t drink and found something kind of shocking. Generally speaking, they were more likely to be unhealthy.

> The people - who did drink… and then stopped… some scientists call them “sick quitters”... Sounds like a bad burn, but basically means they didn't stop drinking because they were running a triathlon, but because they weren’t well.

benno128··on France recalls US and AU ambassadors over sub-deal
I found this article helpful for more context: https://www.thesaturdaypaper.com.au/2021/09/18/the-submarine...

It's by Hugh White the former deputy-secretary of the Australian Department of Defence.

benno128··on DOS Subsystem for Linux
My friends who use WSL have gone the other way. Instead of dual-booting Linux and Windows they now don’t see a need for Linux. Why use compatibility layers like Proton when you can just have Windows?
benno128··on Digital Minimalism: What are the alternative to screen time?
Cooking and baking can be pretty rewarding. If you're into BBQ that's a great activity that takes a lot of time and attention.
← PreviousPage 2 of 2