HNHacker News
TopNewBestAskShowJobs

bhelx

176 karma · joined September 5, 2013

https://bhelx.simst.im/
submissionscomments
bhelx··on Sqlite3 WebAssembly
Chicory has some partial wasip1 support. https://github.com/dylibso/chicory/tree/main/wasi. We use jimfs to keep things simple and secure (and not worry about exposing the real filesystem): https://github.com/google/jimfs

When I did this experiment a few months ago, what we could accomplish was pretty limited. I could load and query databases, but not write to them. However the Chicory wasip1 implementation is advancing.

BTW, we've borrowed a few ideas from wazero so thanks for your work there :)

bhelx··on Sqlite3 WebAssembly
I used the wasm build of sqlite and the Chicory runtime to create a pure JVM executed sqlite library: https://github.com/dylibso/sqlite-zero

It's more of an experiment than an attempt to make something production ready, though I could see it being useful to bring dependency-less sqlite tooling to the JVM ecosystem.

bhelx··on WASM Is the New CGI
Yes, I understand that you can do anything with imports. But that's not part of the Wasm spec. That's a capability the host has decided to give the module. Of course the person with the most privilege can always open holes up, but that capability is not there by default.
bhelx··on WASM Is the New CGI
I agree that it's a problem and I definitely agree with the concern about component model. But maybe Wasm doesn't need 1-1 replacement of all capabilities in the native world. At least not right now. As someone who mostly uses it for plug-in systems, this hasn't been a big issue for us.
bhelx··on WASM Is the New CGI
The statement is correct. Wasm cannot mark memory as executable. It's effectively a Harvard Architecture. The code and memory are split. Furthermore you cannot jump to arbitrary points in code. There isn't even a jump instruction.

> I'm quite convinced the alleged security argument is bull. You can hot reload JS (or even do wilder things like codegen) at runtime without compromising security.

JIT here is referring to compiling native code at runtime and executing it. This would be a huge security compromise in the browser or in a wasm sandbox.

> I don't see any technical reason why this couldn't be possible. If this were a security measure, it could be trivially bypassed.

It's not because it's baked into the design and instruction set. You can read some more about how it works here: https://webassembly.org/docs/security/

> Also, WASM bytecode is very similar conceptually to .NET IL, Java bytecode etc., things designed for JIT compilation.

Yes, and like with Wasm, the engine is responsible for JITting. But giving the user the power to escape the runtime and emit native code and jump to it is dangerous.

bhelx··on RustPython
I can't speak for rustpython, but you can partially evaluate dynamic languages in wasm with something like wizer https://github.com/bytecodealliance/wizer. So you can let the runtime do all the parsing and compiling ahead of time. We do this with javascript (quickjs). It does have a few downsides regarding memory size but it is pretty fast.
bhelx··on Extism makes WebAssembly easy
really enjoyed the talk btw!
bhelx··on Extism makes WebAssembly easy
Come join our Discord if you get the chance and find me there in the ruby-sdk channel. I've been doing some experiments with Wasm and ruby (particularly around rails and higher level application abstractions) and would love to have another rubyist to bounce ideas off of. Also I had trouble tracking down your email, but if you'd prefer you can reach me at ben at dylibso dot com
bhelx··on Extism makes WebAssembly easy
I think I referenced one of your blog post in that article too. So thank you!
bhelx··on Extism makes WebAssembly easy
Hey Simon, I've done some similar experimentation using Extism to sandbox LLM generated code. This uses our JavaScript PDK (which uses quickjs) and can be embedded in any host language we support https://extism.org/blog/sandboxing-llm-generated-code

I'm also working on a Python-PDK right now and hope to have a beta ready in the next month. That would allow us to do something similar with python.

bhelx··on Extism makes WebAssembly easy
This is great so far btw! Going to watch this whole talk today.
bhelx··on Extism makes WebAssembly easy
I've been working on a new Ruby SDK for Extism 1.0 if you want to check it out: https://github.com/extism/ruby-sdk

I added host function support and cleaned up the API a bit.

bhelx··on WASM: Big deal or little deal?
I work on a project for building such plug-in systems. We have a wide variety of languages supported https://extism.org/

> and I’ll want to bundle a bunch of stuff into a standard ZIP file layout (so that documentation, etc. will be easily fetched

I've always, thought it would be cool if Wasm runtimes had a generic supported format for this. Kind of like a Java JAR. But of course, you can implement a custom version for application pretty easily.

bhelx··on Observability in WebAssembly
Yep, should be really soon. Also, we will check out signoz too. Could you see a reason to have an official adapter at some point? The adapter can tie things together for you that the platform expects, like set extra metadata, set trace ids, etc.
bhelx··on Observability in WebAssembly
Thanks Ben! Really looking forward to your WasmCon talk.
bhelx··on Observability in WebAssembly
I have an instrumented version of QuickJS that can be used in the javy toolchain: https://github.com/bytecodealliance/javy

There are two primary goals:

1. Emit metrics directly about the QuickJS runtime similar to node metrics 2. Expose the Observe API as js bindings

With the Observe API exposed to JS, you can do manual instrumentation. I have also instrumented the pieces of QuickJS that invoke JS functions in order to automatically emit spans and it works, but still trying to fill some information gaps to make it more usable than manual instrumentation.

> are you wiring it up like how APM is wired up in JVM applications or what exactly are you doing? Does it effect stack trace outputs or leave those alone?

I can't speak to how JVM does it, but no this does not effect the call stack.

bhelx··on Observability in WebAssembly
One caveat that Datadog (specifically traces) probably won't work on the edge just yet. But if this is something you're interested in kbknapp feel free to post your questions or requests here https://github.com/dylibso/observe-sdk/discussions
bhelx··on Observability in WebAssembly
I do have some experimental code working with QuickJS that does this. Feel free to reach out of if you're interested in trying it out or start a discussion https://github.com/dylibso/observe-sdk/discussions
bhelx··on Sandboxing LLM Generated Code with Extism
Hey HN, we wanted to explore the idea of using Wasm to run untrusted code from an LLM. Would be great if anyone with experience prompt-engineering and LLM tools could improve the code generation model or make a more interactive experience. Here is a repo with runnable code https://github.com/extism/func-gen
bhelx··on GameBox is a programmable, turn-based, WebAssembly game platform
Not really. We've talked about a next step being some kind of development environment for this. Our plug-in playground environment comes close to this, but you can't currently set or use plug-in variables in this tool: https://playground.extism.org/

To make development smoother, what I've been doing is separating the game code and the Extism code. Write unit tests and test harness code against your game code and run it on your host machine.

This can be seen in this tictactoe game in rust: https://github.com/extism/game_box/tree/main/games/tictactoe or this trivia game in typescript: https://github.com/extism/game_box/tree/main/games/wasm-triv...

bhelx··on GameBox is a programmable, turn-based, WebAssembly game platform
Check out the games directory here: https://github.com/extism/game_box/tree/main/games

There aren't yet high quality docs. But if you want to give it a shot I'd try forking one of those and asking questions in the discord: https://discord.gg/tukQnCME

bhelx··on Sandboxing JavaScript Code
I've done this with Extism before. You can now write JavaScript plug-ins that run both on the server and the browser: https://github.com/extism/js-pdk This uses QuickJS compiled to Wasm. You can also embed these into any of the host languages we support, python included. We do have some rudimentary support for HTTP requests as well.

In order to create a plug-in that allows the host to inject and run code, I've done this:

1. Create some kind of export function like `set_code` that takes the string input of the code in CJS format. Example:

``` function myFunc() { return "hello world" }

module.exports = myFunc ```

2. `set_code` can store that text into a plug-in variable with `Var.set('my-function', code)`

3. Create a second export function that can eval the code. Would look something like this:

``` let result = eval(Var.getString('my-function'))() Host.outputString(result) ```

If you're interested I can compile one of these for you. I've been working on a demo that uses a similar technique.

update: fixed some bad javascript

bhelx··on WebAssembly: Adding Python support to WASM language runtimes
Extism does not yet support writing the plugins (our term for Wasm guests) in python. I have been working on javascript support[1] and I think I could use a similar strategy to support python. If you are at all interested in following along or helping out you should join our discord.[2] I just started a #python-pdk channel there.

[1] https://github.com/extism/js-pdk [2] https://discord.gg/mAADpt9r

bhelx··on Extism: Make all software programmable with WebAssembly
Yeah, that's a good idea. C is supported on the SDK and PDK side. We are wondering if Zig can utilize the c libraries for it.
bhelx··on Extism: Make all software programmable with WebAssembly
If you need C# support we can work on it! I've done some experimenting with it already. Please come join the discord or file an issue.
bhelx··on Extism: Make all software programmable with WebAssembly
You can bring your own serialization format. It's just bytes in and bytes out.
bhelx··on Extism: Make all software programmable with WebAssembly
In many ways yes. We need to re-invent many things for this new world. But I'd encourage you to read a bit more about how Wasm is different. It's true it is a stack based virtual machine but that's about where the comparisons end.
bhelx··on Extism: Make all software programmable with WebAssembly
Yes I think that's a good way of putting it. Extism's primary goal is universality. I think the idea of having a plug-in system that is truly universal is exciting. Now we can share and maybe even sell plugins into different ecosystems. No more silo'd environments. I hope to see a future where standards can be built on top of this and plug-ins can outlive the applications themselves. Think VSTs if you are into music software.
bhelx··on Extism: Make all software programmable with WebAssembly
C# support on which side? The host or the plugin side? I've got an experimental C# plugin almost working. I think I can do it. A Host SDK library would be pretty easy since it's just FFI to the runtime.

> Would be nice if Unity games could start supporting wasm plugins

That would be pretty neat! I go back and forth over whether this kind of thing will happen or not. Extism's goal is to be very generic (universal). A game engine may have some competing goals like performance or predictability. Still, I wouldn't be surprised if some alternative engines didn't do this in the next few years.

> Another question... Is something like this possible on iOS or will these kinds of runtimes be banned by Apple?

Not today, but I think I know how to get there.

If you need this stuff for your project come join the discord and we can try to prioritize it!

bhelx··on Extism: Make all software programmable with WebAssembly
I haven't used suborbital yet but yeah, that sounds accurate. We're aimed at being a library and Extism itself is focused on building plug-in systems.

I just signed up for the waitlist! Looking forward to learning more about it.

← PreviousPage 2 of 4Next →