Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upClarify the relationship to bindgen and stdweb #226
Comments
This comment has been minimized.
This comment has been minimized.
|
Right now I definitely recommend stdweb, it's much more production ready: it has many features that wasm-bindgen lacks, and it's really stable (breaking changes are rare). I've written mediumish sized Rust programs with stdweb (~10,000 LOC) and overall it works great. In the long run wasm-bindgen is probably the way to go, and it's improving at a very fast pace. P.S. There are plans to add in full WebIDL support to stdweb. |
This comment has been minimized.
This comment has been minimized.
koute
commented
Aug 31, 2018
|
Author of Basically what @Pauan said.
But if we're talking about the long term I would very much like to make |
This comment has been minimized.
This comment has been minimized.
|
The Rust and WebAssembly domain working group aims to make surgically replacing hot JavaScript functions/modules/libraries with Rust-generated WebAssembly the best choice for fast, reliable code on the Web. We want to have an impact much larger and more widespread than on just the Rust community. Rust, as a language, is ready to rise to this challenge in part because of its zero-cost abstractions. To leverage that on the Web, we need to make very sure that we aren't losing that zero-cost property, and introducing bloat and overhead. We decided that the best way to realize these ideals was to create In general, taking Rust's interoperability with C and the C ABI -- this core tenet that Rust plays well with others -- and lifting that into the JavaScript and WebAssembly domain is an educational lens for viewing the working group's efforts. It explains why With these higher-level philosophical bits out of the way, I'll let @alexcrichton speak to some more of the technical specifics. |
This comment has been minimized.
This comment has been minimized.
|
Thanks for the question about this! I definitely sympathize with the confusion in that these two projects exist and there hasn't been a lot of "official" communication in one way or another about the relationship between the two. In terms of clarifying the relationship between the two projects I think this is something that we can improve on as a working group! @Pauan has been actively participating in the working group but we haven't really talked specifically much about It sounds like there's also a technical part to this question with various claims as well. I'm not personally too familiar with the
Historically Some of the comments here look to be focusing on the WebIDL story for Naturally, however, with auto-generated APIs it's not always a perfect match with what you would have written by hand. The goal of It's absolutely critical to (Note that even with that being said, using To reiterate, I'm not personally too familiar with the details of As for some super-nitty-gritty technical details, I've done some local benchmarking to show where the goals of |
This comment has been minimized.
This comment has been minimized.
|
Oh, also! As alluded to in an earlier comment, |
This comment has been minimized.
This comment has been minimized.
Diggsey
commented
Aug 31, 2018
•
|
@alexcrichton I've used stdweb quite a bit, and have tried to keep up with bindgen etc. as well. I think stdweb should be viewed as having four components:
What I would like to see is for part 1) to be incorporated as a feature of wasm-pack, so that both stdweb and bind-gen based projects can share a common foundation, and eventually remove the need for stdweb's custom build system (or at the very least have it use wasm-pack internally).
Regarding performance, I fully expect wasm-bindgen to be much faster than stdweb. The interop/runtime layer (2) is not optimised at all right now, and also marshals data in a completely dynamic way, whereas wasm-bindgen can generate code at compile time. Stdweb also has to look up references in this global map, whereas wasm-bindgen does not support references at all. |
This comment has been minimized.
This comment has been minimized.
koute
commented
Aug 31, 2018
Yes, I'm not surprised by this at all. (: E.g. I haven't added any special casing for primitives, so currently the same codepath is used for types which are not natively serializable (like e.g.
I'd definitely like to do that! However I still need to be able to emit raw JS snippets from inside of the Rust code. If |
This comment has been minimized.
This comment has been minimized.
|
Don't have time for a proper reply right now, but I will make one on Tuesday.
This is very much possible, see |
This comment has been minimized.
This comment has been minimized.
|
I think it's probably unlikely for |
This comment has been minimized.
This comment has been minimized.
Diggsey
commented
Sep 1, 2018
Ah, I'm sorry, I didn't see this get added. Yes the internal slab allocator for objects covers what I was thinking of. In that case this is another area where stdweb could move to using the same underlying machinery as wasm-bindgen. |
This comment has been minimized.
This comment has been minimized.
koute
commented
Sep 1, 2018
Of course I didn't mean that Ideally we'd have a macro with a prototype of let result: i32 = js_raw!("return $0 + $1;", 1, 2);
assert_eq!(result, 3);This could result in the following import on the JS side: let imports = {
// ...
"env": { // Or whatever else namespace.
// ..
"snippet_04d4c172203e9e30c9a301547926c07ffe64457f": function($0, $1) {
return $0 + $1;
}
}
}Is such a macro out-of-scope too? I guess maybe this could be implemented right now with a procedural macro which would output the snippet into its own file in |
This comment has been minimized.
This comment has been minimized.
|
@koute I think that's probably covered by rustwasm/wasm-bindgen#224 in the sense that what we'd like to do is have a more principled approach at importing local JS snippets (which isn't supported well today). I think it's reasonable though to consider alternative strategies before that's figured out though! In that sense I don't really know if such a macro is in or out of scope, but we could definitely scope it out and see how it goes! It's definitely a goal of |
This comment has been minimized.
This comment has been minimized.
|
Ok so correct me if I'm wrong, but it sounds like this issue is technically resolved in that it sounds like Does that sound right? If so is this perhaps resolved enough to close? |
This comment has been minimized.
This comment has been minimized.
NeverGivinUp
commented
Sep 4, 2018
|
Yes! Perfectly resolved for me. Thank you everyone, for taking the time and explaining the philosophy, motivation and technical side of the relation between wasm-bindgen and stdweb. It made very clear to me that I can use stdweb shortterm and profit longterm all the work that goes into wasm-bindgen. |
NeverGivinUp commentedAug 31, 2018
In my understanding, stdweb aims to only support Rust and thus can be very idiomatic, whereas bindgen aims to more or less be language independent and use webIDL. I don't know if stdweb too is planning to use webIDL in the future.
Bindgen is mentioned regularly in the weekly updates. stdweb is only mentioned once. Is the different treatment of the libraries by accident or by design? Which library do you reccoment for which use case in the short and the long run?