-
Notifications
You must be signed in to change notification settings - Fork 909
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
Better documentation for WASI/WASM #3040
Comments
wazero also maintains this and having written almost all of it, I'm happy to paste it somewhere else also https://wazero.io/languages/tinygo |
I guess it would be super helpful to have these closer to the TinyGo documentation. But, especially for developers using JavaScript (as in the current example), there is still no good docs on more complex scenarios for WASI. |
Easy enough to add some links to the tinygo wasm docs page or equivalent. If it doesn't end up on the tinygo site proper I'm sure we can find some place for it to live. |
@brunoluiz ack. the wazero page won't get into details of browser use much as it is vast, and wazero embeds in go apps which aren't likely to include a javascript interpreter. the only reason we cover GOOS=js is because Go has no other option at the moment. I've been told that how the |
last thing on wazero's page: https://wazero.io/languages/tinygo/#system-calls only applies to the wazero has a little bit of content on WASI here and I'll add more later, as a top-level page. WASI weirdness applies to all languages that use it and so there's some required reading I think in general before trying to get complex into one language https://wazero.io/specs/#wasi one "more complex scenarios for WASI" One thing I noticed in writing docs, is that I've never been able to guess what people think. I would recommend that you mention examples of complex scenarios you are interested in. Ex without guessing, what I would probably add examples to the internals part, how to run TinyGo tests for the wasi code, and any other things needed to help develop them. That's because in my world view, that's what I notice developers struggling with.. how to fix a gap, how to know where to start, how to know what tool to use to fix a gap. TL;DR; is maybe add to the description some bullet points of key things you personally would like to see covered, and be very specific. my 2p! |
@codefromthecrypt Hey, I am using WASM just as a side thing, so I wouldn't have plenty of examples to give. I will add some to the description, but probably someone that works daily with this might be better suited for giving "real-life" scenarios/examples. |
Is it safe to assume that those targeting the web are left with the only option to wait for WASI to land in Go so that we have access to both the host operating system and the DOM at the same time without using JS? Also is it true that TinyGo looks at using WASI for its non-web functionality rather? |
@mar1n3r0 I'll try to answer.. golang/go and tinygo-org/tinygo are alternative compilers of go source to WebAssembly. Both support For example, https://github.com/tinygo-org/tinygo/blob/release/targets/wasm_exec.js Note that the So, if you compile go source via Currently only tinygo can compile to Hope this helps! |
Thanks @codefromthecrypt already aware of the js glue. The question is more about wasm and web without js. There was a spec in the past about interface types which would allow for wasm to access the DOM. And wasi for accessing the host os. It would be great if both can be combined for a complete alternative to js in the browser. From what I understand though wasi is aiming to rather be an alternative to containers outside the browser. What I am missing is if wasm and wasi can be combined for the web making js completely obsolete. In the grand scheme of things my main problem is that we can't access the DOM with anything else but js. It's become a dangerous monopoly leading to no choice for frontend dev. Perhaps I should paraphrase to: can tinygo target wasi compile to wasm which is for the web? References: golang/go#31105 |
I think I need to defer to others, but last hint is that the people who maintain WASI are using interface types. wit-bindgen could have a plugin to generate tinygo stubs alongside other languages. This might be a breadcrumb helpful to figure out the DOM story (which would need host imports I think and in that case would be WASI+something else, but I could be wrong on that) |
Thanks. Seems to be not applicable for web as it works directly with the WebAssembly language and .wit and .wat rather than Go to wasm compilation. I suppose the solution will come from Go rather than from bytecodealliance for the web use case. |
tinygo-org/tinygo-site#352 addresses some of the specific points in this issue. I am marking this one to be closed on next release. Thank you everyone! |
This is part of the |
I am developing a toy project using TinyGo and it works quite well when using as a drop-in replacement for Golang. But, if I try to use only WASI, replacing
syscall/js
with only what WASI provides, it is not exactly clear how to deal with some aspects of it. TinyGo is short of documentation in this aspect and, from what I searched in the issues here, there are many things that are not as simple to infer.My suggestions are:
Some references I used:
EDIT: As suggested on the PR, we could have some more elaborate WASI + JS examples, such as:
_, error
is not standard in WASI)The text was updated successfully, but these errors were encountered: