4 ms·
So, was this a delayed April Fools joke/project that had to wait until the anti-April Fools backlash of 2020 subsided? I wonder how many other projects like th
by ebiester 7y ago
So, was this a delayed April Fools joke/project that had to wait until the anti-April Fools backlash of 2020 subsided?
I wonder how many other projects like this were cancelled or delayed.
- jgrahamc 7y agoThis is not a joke at all. We are serious about WebAssembly in our serverless platform and showing that it can support languages like COBOL is important.
- StavrosK 7y agoThe hardest part about WebAssembly that I found is that very few projects document their ABIs. For example, I want to write a Rust WebAssembly program to do whatever with CloudFlare workers (literally anything, just to try it). Is there a page listing all the functions I can import and call? IIRC I had only managed to find some "hello world" examples, ran them, they did indeed say hello world, and then I thought "well okay, now I know how to return stuff and nothing else" and gave up because I couldn't find documentation on other calls.
- steveklabnik 7y agoSo, to take a few steps back, maybe you know some of this: First off, you write some wasm. You export some functions from the wasm. How you do this is up to your Rust code. wasm-bindgen would be the low-level details here. Then, in your worker, you import the wasm. This shouldn't change from the templates, really. What signatures the imported functions have depends on how you exported them. There's no inherent restrictions about what you can call, it's about knowing what you've exported and then calling them with the appropriate stuff. So for example, https://github.com/jRiest/the-best-goats https://github.com/jRiest/the-best-goats is a little Rust wasm app. This app was built before wrangler existed, so it's got some strangeness, but it does work. https://github.com/jRiest/the-best-goats/blob/master/src/lib.rs#L518 https://github.com/jRiest/the-best-goats/blob/master/src/lib... is the main. I am not entirely sure how jake did this, but it looks like he compiled it to wasm, and then added https://github.com/jRiest/the-best-goats/blob/master/index.js#L737-L749 https://github.com/jRiest/the-best-goats/blob/master/index.j... at the bottom. Wrangler would make this a bit easier, of course. Regardless, you can see how these lines, which are the standard Worker entry point, calls into the main defined in wasm. Does that help at all? It is certainly true that this is not as well documented as it could be. Lots of work still to do.
- StavrosK 7y agoAhh, yes, that helps a lot, thanks Steve! I missed the fact that the wrapper is what the backend communicates with, and then the wrapper calls wasm. I thought the backend would call wasm directly (and that I could just not have a JS wrapper at all). It would be extremely helpful if this was mentioned somewhere on the starting docs (maybe it is and I missed it?).
- steveklabnik 7y agoAny time! Where did you look for this information? I can file a bug, but knowing where to put it would be helpful.
- StavrosK 7y agoGreat question. Because I was thinking that I could use workers with just rust, I Googled for "CloudFlare workers rust" and ignored anything that had JS in it. I can tell you where I probably was when I get to my computer if you want, it was probably the CloudFlare articles about Rust and workers. EDIT: Oops, looks like I replied to my own comment before, HN mobile app fail. Luckily, you saw the reply.
- steveklabnik 7y agoCool thanks :) I think that's still helpful.
- StavrosK 7y agoNo problem! I looked again, and I think I looked around at the blog articles, wrangler and messed a bit with the examples, then didn't make much sense of it and gave up. I would have had much better luck if I had seen what you told me, ie "you can call wasm from JS" rather than thinking I could somehow execute wasm directly on the worker. Thanks again!
- atonse 7y ago
- steveklabnik 7y agoCloudflare has a pretty solid anti-April Fool’s culture. There’s always a serious announcement on April Fool’s.