Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

What's the state of wasm for porting multi-process code?

I want to run something that execs a command line tool, both in the browser. Doable yet?



> I want to run something that execs a command line tool, both in the browser. Doable yet?

If it's not possible from Javascript, it's also not possible from WASM, it's as easy as that.

If your command line tool can be compiled to WASM and works within the restrictions of the browser sandbox, it's trivial. But if you want to start a native command line tool from within the browser, it's pretty much impossible (and for good readons).

There's also a grey zone if you need it to work in a specific runtime environment. For instance VSCode extensions allow to run POSIX command line tools compiled to WASI, and those can safely access parts of the filesystem (like reading and writing files in the current project directory).


I meant: I want a program compiled to wasm capable of running in the sandbox calling another command line tool also compiled to wasm.

Right now the call is through an exec system call, but that can be changed.


In VSCode extensions this is trivial, this is how you create the 'executable':

https://github.com/floooh/vscode-kcide/blob/main/src/wasi.ts

...and this is how you run it:

https://github.com/floooh/vscode-kcide/blob/2dfc621aade4a2be...

The asmx.wasm file is a vanilla POSIX cmdline tool which loads and saves files via fopen/fread/frwrite/fclose, and the tool has been compiled with the WASI SDK: https://github.com/WebAssembly/wasi-sdk

The resulting VSCode extension (https://marketplace.visualstudio.com/items?itemName=floooh.v...) then even runs in the VSCode browser version (https://vscode.dev/)

But AFAIK there's currently no easy way to get a similar easy to use WASI wrapper in browsers (it's definitely possible though because the VSCode browser version does it - VSCode basically has a filesystem abstraction which works for native filesystems as well as virtualized web filesystems like github repositories).


We have a research project called WALI (WebAssembly Linux Interface) here: https://github.com/arjunr2/WALI

It's experimental, but there is a toolchain that can compile most C/Posix programs and run them on the prototype implemented in the WAMR engine. And yes, exec works! In fact, we are able to run bash and Lua and memcached, among other things.


Neat! Let me take a look.


most of that is happening above the WebAssembly spec: https://wasi.dev/

More specifically for command line tools:

- https://wasi.dev/interfaces#presentation

- https://github.com/WebAssembly/wasi-cli


Is wasi .3 still planned to finish soon like the roadmap said? so wasi 1.0 is the the next goal?

wasi 1.0 feels like when it will take off after all these years of dev

timeline at the bottom of this page: https://wasi.dev/roadmap



Check https://wanix.sh/ you may like it :)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: