3 ms·
>> Wait, there's something here that I'm not getting. Why are you compiling the code to WebAssembly instead of just running it directly on the server? > Well,
by skinkestek 2y ago
>> Wait, there's something here that I'm not getting. Why are you compiling the code to WebAssembly instead of just running it directly on the server?
> Well, everything's a tradeoff. Let's imagine a world where you run the code on the server directly.
> If you're using a language like Python, you need to have the Python runtime and any dependencies installed. This means you have to incur the famous wrath of pip (pip hell is a real place and you will go there without notice). If you're using a language like Go, you need to have either the Go compiler toolchain installed or prebuild binaries for every permutation of CPU architecture and OS that you want to run your infrastructure on. This doesn't scale well.
> One of the main advantages of using WebAssembly here is that you can compile your code once and then run it anywhere that has a WebAssembly runtime, such as with the yoke CLI or with Air Traffic Controller.
At this point, why not use a proper runtime like JVM or .Net?
Then one can also easily use reasonable languages like C#, Java or Kotlin as well.
- LoganDark 2y ago> At this point, why not use a proper runtime like JVM or .Net? Because then you are forced to only use managed languages?
- skinkestek 2y agoAhh, good point. I guess Rust (and maybe other unmanaged languages) can be compiled to WebAssembly?
- xena 2y agoYes: Go: https://go.dev/blog/wasi https://go.dev/blog/wasi Rust: https://github.com/bytecodealliance/wasmtime/blob/main/docs/WASI-tutorial.md https://github.com/bytecodealliance/wasmtime/blob/main/docs/...
- politelemon 2y ago.net: https://devblogs.microsoft.com/dotnet/extending-web-assembly-to-the-cloud/ https://devblogs.microsoft.com/dotnet/extending-web-assembly...
- LoganDark 2y agohttps://logandark.net/calc https://logandark.net/calc is C++ compiled to WebAssembly using Emscripten. Back from I think 2018. These days Rust is practically the poster child of compiling to WebAssembly because it's so easy. Most WASM content I see is actually about Rust.
- sunrunner 2y ago> a proper runtime like JVM or .Net? Or (god forbid) a proper runtime like just the OS and architecture of the platform you're running the tool on. This article calling out Go because you have to prebuild binaries for every OS and architecture combination beforehand (even though you probably already know this combination and it's likely small) and saying that doesn't scale but then requiring every user to not just get the WASM binary they want to run but _also_ just get the (OS and architecture-specific) runtime for the environment seems unfair. Anything where you distribute your application in a way that isn't immediately usable on a target platform without having to set up an environment of some kind feels like a 'Shift right deployment' kind of thinking, where it's fine to do the bare minimum to make your tool available and it's now an end user's problem to get everything set up to run it. In some cases this is fine and the cost is low (same-language library usage for example) but when it comes to tool distribution every time I see 'cargo install' for someone's cute Rust project or an instruction to 'just do the following ten steps and you can run the executable' I usually just back away from GitHub and don't bother.