News for hackers. Stuff that matters.
Re:WebAssembly: Docker Without Containers by mike_hearn on Wednesday December 21, 2022 @08:45AM (#34080624)
Can you actually compile an arbitrary program to WASM? I thought they had to be ported to WASI first and can't use any operating system APIs. Otherwise, how can it be sandboxed? Arbitrary programs can call into arbitrary OS-native APIs and execute arbitrary native code outside the bounds of the WASM VM, including things like JITing native code.
Re:WebAssembly: Docker Without Containers by orf on Wednesday December 21, 2022 @08:50AM (#34080693)
It depends on the program being compiled, but yes you can.

You can run Postgres using WASM in two different ways[1][2]. That’s a non-trivial codebase.

1. https://www.crunchydata.com/blog/learn-postgres-at-the-playg...

2. https://supabase.com/blog/postgres-wasm

Re:WebAssembly: Docker Without Containers by mike_hearn on Wednesday December 21, 2022 @09:06AM (#34080877)
That works by compiling some sort of Linux VM into WASM as well, which isn't arbitrary programs (that would have to include Windows and macOS programs too).
Re:WebAssembly: Docker Without Containers by orf on Wednesday December 21, 2022 @09:21AM (#34081044)
I feel like you’re nitpicking and ignoring the actual argument you originally made?

You can compile arbitrary programs to WASM, like you can compile arbitrary programs to x86 or ARM. It’s effectively a CPU target. You can take the whole of Python and SQLite, compile them to WASM and run a web framework on top of that via WASM in the browser[1].

If those programs utilise specific os-level behaviour that can’t be shimmed, or explicitly throw an error when being compiled to WASM then of course they won’t work without modifications.

Meanwhile, the JVM is not anything like a CPU target. It’s a very high-level VM designed for a particular type of language.

1. https://simonwillison.net/2022/May/4/datasette-lite/