Skip to content

play with wasm_bindgen for IDL#138

Closed
chenyan-dfinity wants to merge 8 commits intomasterfrom
idl_wasm
Closed

play with wasm_bindgen for IDL#138
chenyan-dfinity wants to merge 8 commits intomasterfrom
idl_wasm

Conversation

@chenyan-dfinity
Copy link
Contributor

@chenyan-dfinity chenyan-dfinity commented Nov 4, 2019

This works locally on my machine. Will try to build with nix.

Observations:

  • Exported Rust function cannot have type variable
  • Export C-like enum only
  • Box<[JsValue]>, Result<T, JsValue>

JS code

    const bytes = js.js_encode([42,false, "哈哈",  { 'ok': 42, 123: 'test' }, [[1,2,3],[4,5]]]);
    console.log(bytes);
    const args = js.js_decode(bytes);
    console.log(args);

@hansl
Copy link
Contributor

hansl commented Jan 24, 2020

@chenyan-dfinity What's the status here?

@chenyan-dfinity
Copy link
Contributor Author

What's our plan for wasm_bindgen?

It's working locally on my machine, but no nix support. We can keep this branch as a playground. Or I can absorb the code into the IDL rust library.

@hansl
Copy link
Contributor

hansl commented Jan 24, 2020

Do we need a plan for wasm_bindgen? What are the benefits of having support?

@chenyan-dfinity
Copy link
Contributor Author

What are the benefits of having support?

  • No need to maintain a JS Userlib.
  • No language gaps: everything is in Rust.
  • Assuming we trust wasm_bindgen, no specific testing for JS side.
  • Serving both frontend and backend in WebAssembly.

Do we need a plan for wasm_bindgen?

I don't know. Given that we already have a JS userlib, it may not be a priority for SDK. But it's nice to have. Maybe when we open source, the community can build something similar for us.

@hansl
Copy link
Contributor

hansl commented Jan 24, 2020

No need to maintain a JS Userlib.

We would still have to maintain a userlib, just the IDL part would go away. And since we'll most likely have to maintain some kind of library for many languages, I don't see this as a big negative.

No language gaps: everything is in Rust.

Until we need to support another language.

Serving both frontend and backend in WebAssembly.

Apps will still have a JavaScript part.

@chenyan-dfinity
Copy link
Contributor Author

We would still have to maintain a userlib, just the IDL part would go away.

We can apply wasm_bindgen to most of the dfx codebase, so we can replace all the userlib JS code, e.g. http_agent, request, etc.

And since we'll most likely have to maintain some kind of library for many languages, I don't see this as a big negative.

I think the idea is that with (hopefully) most language supporting WebAssembly, we don't need to maintain libraries for many languages.

No language gaps: everything is in Rust.

Until we need to support another language.

We already have gaps between JS and Rust. Every new feature/bug fix needs to be done twice, in both languages.

Serving both frontend and backend in WebAssembly.

Apps will still have a JavaScript part.

Not necessarily :)

@hansl
Copy link
Contributor

hansl commented Mar 10, 2020

I'm going to close this as it's at least 4 months old.

@hansl hansl closed this Mar 10, 2020
@lwshang lwshang deleted the idl_wasm branch July 29, 2022 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants