4 ms·
Does WebAssembly even make sense as a standalone runtime, like the JVM? Is "server-side WebAssembly" going to be "a thing", or is it just a compatibility kludge
by nerdponx 5y ago
Does WebAssembly even make sense as a standalone runtime, like the JVM? Is "server-side WebAssembly" going to be "a thing", or is it just a compatibility kludge?
And what of all these languages that compile to JS, like Typescript, Reason, Kotlin, et al? Is JS a sound "IR" between the frontend and WebAssembly? Or would it be better to compile things directly to WebAssembly?
- gpm 5y agoYes, wasm makes sense as a standalone runtime. It's basically just like any other bytecode. Like any bytecode (including jvm's), it comes at a performance penalty over bare asm. I personally don't anticipate it will replicate jvm's success as being a runtime when there is no reason for a runtime to exist - since it shouldn't be much harder to compile wasm (and languages that compile to wasm) to native asm ahead of time. On the other hand I wouldn't have predicted jvm's success either. In places where you want a runtime though, like in shared computation models where it gives you security/performance advantages, it makes perfect sense. It looks like it's probably going to succeed there to me. Compiling X -> JS -> Wasm doesn't make much sense. Not only is wasm a language with cleaner semantics to compile to, but JS doesn't actually really fit wasm semantics particularly well. In fact, while I could have missed something, I'm not aware of any good JS->wasm compilers. The closest I can think of is https://www.assemblyscript.org/ https://www.assemblyscript.org/ - and it's not 100% JS compatible.
- invokestatic 5y agoI think a lot of people, myself included, have been waiting for a low-level, polyglot, and lighter weight runtime than the JVM. WebAssembly currently provides the best tooling for this. That said, I’m not really convinced of the server-side use case except for sandboxing untrusted code. Especially in rust, where the language itself provides safety guarantees that the VM makes redundant.
- zozbot234 5y agoThe safety guarantees are not redundant, they're quite complementary. WASM doesn't protect you from violating memory safety within your programs; its sandbox only protects the rest of the system from whatever the WASM program does.
- pjmlp 5y agoWhy waiting? There have been plenty of similar stacks, JVM is just one among many.
- simonw 5y agoI think server-side WASM is going to be huge, because it could finally give us an easy to run code in a secure sandbox. Imagine being able to run a complex C dependency (with a high risk of buffer overflows) risk-free because it's running in a WASM sandbox? Or building features that allow users to provide their own executable code (for plugins and extensions and other customization features) where they code is executed in a sandbox with strictly controlled CPU/memory/network and API access control.
- Matthias247 5y agoI’m not sure the amount of C code that one wants to run into a server that is not system level code (doesn’t make syscalls itself and implements the server/ business logic) is noticeable. And only if that would be the case the use of WASM would be an advantage. For general extensibility we had Java servlets, Lua modules, PHP modules, etc in webservers for decades. Maybe it’s interesting for source code obfuscation purposes or in order to allow migration of server logic between different languages. But even that was possible before - and I don’t think the Market need was huge.
- watermelon0 5y agoThere are many tools such as ffmpeg, that you might want to run on untrusted input (e.g. file uploads), and in many cases performance is not that important. Java servlets, Lua and PHP modules cannot be run securely, and there are vulnerabilities for all of them.
- fiddlerwoaroof 5y ago> Java servlets, Lua and PHP modules cannot be run securely, and there are vulnerabilities for all of them The thing is, the JVM was designed with the explicit intention of making it possible to run untrusted code safely: how do we know we got it right this time? The problem really isn't the VM, it's the APIs and authorization model for access to the underlying system's features.
- 5y ago
- dgb23 5y agoThere was a fairly recent article from Cloudflare providing tooling support for Rust->WASM on their Workers (serverless, sandboxed HTTP/Web centric plattform). WASM has some interesting properties, like sandboxing, a small set of instructions you can fit in your head and some fairly high level constructs (for a compilation target). However I don't quite know what other benefits it provides. It certainly cannot compete with the JVM/CLR on many fronts. And I don't see quite a lot of use-cases yet that cannot be covered with just integrating V8. Happy to learn more about that (actual rationales).
- ignoramous 5y ago> Does WebAssembly even make sense as a standalone runtime, like the JVM? Is "server-side WebAssembly" going to be "a thing", or is it just a compatibility kludge? Yes, see: https://bytecodealliance.org/articles/1-year-update https://bytecodealliance.org/articles/1-year-update > Or would it be better to compile things directly to WebAssembly? It'd be even better to roll out one's own Lambda@Edge: https://krustlet.dev/ https://krustlet.dev/
- BiteCode_dev 5y ago1 - it's sandboxed by default 2 - it's the only things that also run on the web 3 - it's probably going to be ubiquitous because of that, meaning it will be a great platform to target by default 4 - it could potentially mean any platform run any code from any other one without having to deal with wrappers: you would write a lib in go or rust, and then run it as is in python
- pjmlp 5y agoSomeone just rediscovered IBM TIMI,Amsterdam Compiler Kit EM, CLR MSIL, among plenty of others. Sandboxing is of little help when external events can cause internal memory corruption that change module's expected outcomes. It is as good as typical OS process.
- japanuspus 5y agoNot just for web either: if you ship WebAssembly bytecode as part of your python package, you can push your platform dependencies out to a wasm runtime and skip most of the build matrix. A runtime like wasmer-python [0] is only 1.5MB. [0]: https://github.com/wasmerio/wasmer-python https://github.com/wasmerio/wasmer-python
- fragile_frogs 5y ago> If WASM+WASI existed in 2008, we wouldn't have needed to created Docker. Source: https://twitter.com/solomonstre/status/1111004913222324225?lang=en https://twitter.com/solomonstre/status/1111004913222324225?l...