4 ms·
Why did you opt for WASI for plugins instead of native compiled code?
by DeathArrow 5y ago
Why did you opt for WASI for plugins instead of native compiled code?
- conradludgate 5y agoEither the plugin needs to be written in a common language (JS for VSCode, Python for Sublime Text) or native (Terraform does this for custom providers) but need to support many architectures. WASI fits snuggly in between, being a common intermediate language
- ReleaseCandidat 5y agoBut JS _is_ a common intermediate Language. I guess more languages compile to JS than to WASM.
- pbronez 5y agoWASM actually started life as a subset of Javascript called asm.js. Code in other languages was compiled to this subset of Javascript so they could execute in the browser. Once that proved useful, they decided to skip the Javascript step and agree on a binary format that browsers could execute directly. That's WASM. From https://en.wikipedia.org/wiki/Asm.js https://en.wikipedia.org/wiki/Asm.js > asm.js consists of a strict subset of JavaScript, to which code written in statically-typed languages with manual memory management (such as C) is translated by a source-to-source compiler such as Emscripten (based on LLVM).[2] Performance is improved by limiting language features to those amenable to ahead-of-time optimization and other performance improvements. > asm.js is mostly rendered obsolete with the introduction of WebAssembly (wasm), which has a bytecode format that is faster to parse. Efforts to extend JavaScript with more low-level features like SIMD.js has also been suspended since 2017. asm.js remains useful primarily as a "fallback" for wasm
- UtherII 5y agoIt can used as an intermediate language, and since it was the only way to run code on the browser without plugins before WASM, it happened a lot. But nowadays WASM is much more suitable for the job. JavaScript was designed as a scripting language, not a low level intermediary language.
- stefs 5y agonot OP, but i think it makes sense. there isn't that much of a speed difference and you get free sandboxing, some memory safety, a ton of supported languages and more. i don't know anything about WASI, but it probably solves the problem of having to interface with different native compiled code ABIs.
- dzhou121 5y agoI think native compiled code is hard for plugin distributions. You'll need to target 3 main platforms Linux/macOS/Windows. You can use github actions to do it, but it would be so easier to just compile to WASI and that's it. Also, WASI is compelling to me because of the potential of writing plugins in different programming languages.
- DemocracyFTW 5y ago> WASI is compelling to me because of the potential of writing plugins in different programming languages I think this is the future really, I've been pining for this to become a thing for so long.
- stavros 5y agoI think WASI is an excellent idea. Do you know how the ABI works?
- froh 5y agomultiply that with the CPU ISA, like arm, x86 (and more if you are inclined to support power, sparc, ...)
- the_duke 5y agoWebassembly makes a lot of sense for plugins. * sandboxing, so plugins don't need to be as trusted * Easy cross-platform distribution with a single build artifact * plenty fast (if written in a language like Rust/C++ and paired with a good runtime)
- chrisjc 5y agoApologies for lack of my lack of knowledge in this area, but... Why don't plugins "need to be as trusted"? Obviously bad-actor plugins would be less effective and capable of inflicting any sort of attack on your development OS, but surely the development environment is the perfect vector for attacking the runtime environments that run your artifacts get deployed into? Not to mention the potential for secrets-harvesting due to sloppy boot-strapping dev-env habits or other bad habits we often engage in during the early development process? Or does WASI somehow provide protection from these issues?
- laumars 5y agoThe clue is in the first part of the GPs sentence which you latched onto: “sandboxing”. The code is running inside a virtual machine rather than natively on the host.
- chrisjc 5y agoNo, I got that. I understand how the host is protected, but didn't understand how everything inside the "VM" was protected... @galgalesh answers that above.
- galgalesh 5y agoIt's all about reduction of surface and giving plugins access to the least amount of info. You expect a linter to only have (read) access to the code it lints. It shouldn't be able to modify files, it shouldn't have network access etc. WASI has a pluggable capability-based security system. Some advanced linters might want network access but you can show this to the user, so they can make an informed decision about whether to trust that linter and their author with this power. This isn't airtight security to protect against obviously-malicious authors. This is about creating a system that can deal with the reality that "trust" in an app store entails "a million shades of gray". I might trust a plugin enough to check for errors in my code, but not enough to actually modify my code.