Remix.run Logo
mercutio93 5 hours ago

Intresting question truth be told I went for tried and tested docker since its something industry uses without "issues" (I say that lightly cause they are).

I have to say that you can definately get further with a WASM VM today. pyodide can run libraries like numpy/pandas and WASIX (WebAssembly System Interface Extended that adds missing syscalls, dynamic linking, threads, sockets, libffi) can get a full cpython with native libs running but those are specific curated packages. The idea behind the0 was to bring the exact environment, whatever pip wheel or C binding you used backtesting locally runs unchanged in the container. With WASM anything outside the curated package list needs a wasm-specific build to exist at all as wasm is a different architecture straying from x86/ARM.

On language support I actually went through my 7 runtimes for this. Rust is the only one where wasm is a first-class target today. C/C++ has been clang-only for a decade, GCC's own wasm backend literally got approved by the steering committee last month and its still missing exceptions and debug info. Python as above runs as curated interpreter builds. Node is the funny one, wasm VMs dont run JS at all, you embed a JS engine compiled to wasm (Javy, StarlingMonkey) and lose all the Node APIs and native addons. The .NET 8 WASI workload is labelled experimental by Microsoft. GHC's wasm backend arrived in 9.6 and is still young. And for scala 3 the closest thing is Scala.js's new WasmGC backend, but thats Scala.js semantics, you lose the JVM library ecosystem which is the whole reason to write a bot in Scala. So 1 out of 7.

I did have a look at what would close the gap here. container2wasm is a possible hopeful solution but it does this by embedding a CPU emulator (Bochs) and booting linux inside the module so theres a emulation tax here I think I havent tested it. Theres also runwasi that solves the opposite problem, it would let docker/k8s schedule wasm modules as if they were containers. A glimmer of hope, however it wouldn't change the fact that we would have to compile to wasm first (back to fiddling with pyodide and WASIX). So we could either recompile the ecosystem or emulate the CPU.

That said for simple pure-logic bots a wasm runtime alongside the containers could be nice someday, the isolation and cold starts are genuinely better. Worth doing an expiriment and protoype of this. But for running whatever code in whatever language today, docker gets 7 out of 7 cause containers are the ISA everything was already built for, its the industry standard for production workloads for a reason.