3 ms·
> embedding a WebAssembly runtime gives you all of that plus the ability for people to easily write plugins in any language No, you would still have to provide
by zzzcpan 7y ago
> embedding a WebAssembly runtime gives you all of that plus the ability for people to easily write plugins in any language
No, you would still have to provide an application programming interface for every target language you want to support.
- JoshTriplett 7y agoNo, you don't. If you export functions to WebAssembly, any language that can run in WebAssembly can call those functions. And if you define WebAssembly Interface Types for your exported functions (note: still in development), any language that handles interface types can automatically handle things like "how does this language represent a string safely". Either way, you don't need to define a new API for every language.
- zzzcpan 7y agoWhat you are describing is more like __asm__("") in C, not an interface for application developers. Those are still required for every single target language because of the mismatch between the levels of abstractions between those languages, webassembly and actual logic exported.
- JoshTriplett 7y agoThat's not accurate, and people are not expected to write an API adapter for every target language. Please read https://hacks.mozilla.org/2019/08/webassembly-interface-types/ https://hacks.mozilla.org/2019/08/webassembly-interface-type... . Interface Types are the mechanism for handling the different abstractions in different languages without having to write language-specific interfaces. WebAssembly prior to Interface Types is more akin to an exported C function than to inline assembly. That already gives you enough for many kinds of interfaces, most notably the common pattern of obtaining an opaque handle and calling functions on that handle. WebAssembly with Inteface Types gives you everything needed for high-level interfaces in any language. That lets you define strings, buffers, handles, arbitrary structured types, and pretty much anything you'd expect of a high-level interface.
- zzzcpan 7y agoI have read the article, when it came out actually, it's merely about type mapping rules to an intermediate common representation. And it absolutely doesn't imply that interface types give you everything for high level interfaces in any language. Not that it's even possible, as high level <-> wasm <-> another high level transformation cannot realistically be automated for an arbitrary high level language, what can be is just high level <-> wasm <-> wasm level looking code in another high level language. It's like decompiling, you can't produce high level code automatically, only low level looking code in high level languages.