News for hackers. Stuff that matters.
Re:Show HN: Open-source web embeddable code runner by benno128 on Saturday November 20, 2021 @04:58PM (#29292239)
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!

Re:Show HN: Open-source web embeddable code runner by kiwicopple on Saturday November 20, 2021 @09:44PM (#29293735)
This is very cool - I’ve wanted to do something like this on our docs at supabase. I’ll give it a go!

I see that you did a lot of work to make it function on iOS. Is there a fallback mechanism for older browsers where this wouldn’t be supported?

Re:Show HN: Open-source web embeddable code runner by benno128 on Sunday November 21, 2021 @12:42AM (#29294457)
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!

Re:Show HN: Open-source web embeddable code runner by syrusakbary on Sunday November 21, 2021 @04:48PM (#29300082)
This is really awesome. I'm super stoked to find more companies and developers leveraging on the power of Wasmer and WAPM to empower new use cases.

Great work!

Re:Show HN: Open-source web embeddable code runner by benno128 on Sunday November 21, 2021 @05:19PM (#29300326)
Thanks Syrus! The stuff you're all building at Wasmer has been really useful (and is super cool).
Re:Show HN: Open-source web embeddable code runner by valstu on Sunday November 21, 2021 @04:08PM (#29299736)
Could I build webassembly.studio like page with Runno (compile C code to webassembly)?
Re:Show HN: Open-source web embeddable code runner by benno128 on Sunday November 21, 2021 @05:20PM (#29300339)
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.