Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Wasm for plugin mechanism #40

Open
eduardomourar opened this issue Dec 4, 2021 · 6 comments
Open

Use Wasm for plugin mechanism #40

eduardomourar opened this issue Dec 4, 2021 · 6 comments
Assignees
Labels
enhancement New feature or request

Comments

@eduardomourar
Copy link

Is your feature request related to a problem?
Currently, plugins for Smithy can only be developed in Rust, but I would like to use TypeScript (AssemblyScript) instead.

Describe the solution you'd like
By using a different plugin system based on Wasm [1], any language that can target WebAssembly (which includes Rust) can be used to extend Smithy. It is important to note that Rust provides first class support for WebAssembly [2] and that others have used that same mechanism successfully [3] [4].

Describe alternatives you've considered
You can find a few alternatives with explanations in this blog post [4].

Additional context
[1] https://webassembly.org/
[2] https://sendilkumarn.com/blog/rustwasm-introduction/
[3] https://istio.io/latest/docs/concepts/wasm/
[4] https://nullderef.com/blog/plugin-tech/#wasm

@stevelr
Copy link

stevelr commented Dec 5, 2021

I'm curious to know what's the use case. I'm not sure I get why a webassembly plugin makes sense here. Most of the rust-atelier features are in libraries already, and the plugin model as described in some of those links above are more applicable to servers or cli tools.

@swaits
Copy link
Contributor

swaits commented Dec 6, 2021 via email

@johnstonskj johnstonskj added the enhancement New feature or request label Dec 6, 2021
@johnstonskj
Copy link
Owner

I wouldn't say it has no place, if there was a clear need to support polyglot plugins where anything that can compile to WASM works, it would be an interesting approach. Currently the intent is to support the Rust community with Rust-native tooling.

@johnstonskj johnstonskj self-assigned this Dec 6, 2021
@swaits
Copy link
Contributor

swaits commented Dec 6, 2021 via email

@eduardomourar
Copy link
Author

My intention here was to bring this up in the core Smithy repository (smithy-lang/smithy#1001), but it makes more sense if using Rust than in Java where you would have the overhead of introducing another VM. From my personal perspective, I would like to use Smithy but I have limited knowledge of both Rust and Java (the same applies in the company I work for). So, if the AWS intention is to make the Smithy ecosystem broader, then Wasm should at least be considered as a viable approach.

@stevelr
Copy link

stevelr commented Dec 6, 2021

In case it's useful to anybody here, I wrote a rust library weld-codegen that uses rust-atelier to build models from .smithy files, and generate Rust traits, structures, and other types. The generated code does run in WebAssembly, and in fact does sort of support a plugin model (with wasmcloud). The only complete code generator is for Rust but more target languages should be supported in the future.

To be clear, weld-codegen (and rust-atelier that it's built on) is only invoked from cli tools, and there is no rust-atelier code being used from within the generated code or from WebAssembly. rust-atelier has dependencies on file io and other libraries that don't work in wasm. so porting it to wasm would take some non-trivial work.

The code generator is part of the open source wasmcloud ecosystem, but there aren't dependencies on wasmcloud and I hope that it can be generally useful to others for other purposes. Please let me know if you're interested in collaborating on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants