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
Add a general purpose console.log() import. #11
Conversation
Many WebAssembly tutorials, including the example code on MDN, use a `"console" "log"` import. I thought it would be good to add this import to avoid confusion when people copy/paste example code into their Exercism exercise. `WasmRunner` has plenty of alternative logging functions (including `log_i32_u()` that is also just a `console.log()` call) but it's not obvious they exist if you don't look into this source file. And if you're a WASM beginner (like me) you might not even realize that the `"console" "log"` import has to be defined somewhere ahead of time.
Hello. Thanks for opening a PR on Exercism 🙂 We ask that all changes to Exercism are discussed on our Community Forum before being opened on GitHub. To enforce this, we automatically close all PRs that are submitted. That doesn't mean your PR is rejected but that we want the initial discussion about it to happen on our forum where a wide range of key contributors across the Exercism ecosystem can weigh in. You can use this link to copy this into a new topic on the forum. If we decide the PR is appropriate, we'll reopen it and continue with it, so please don't delete your local branch. If you're interested in learning more about this auto-responder, please read this blog post. Note: If this PR has been pre-approved, please link back to this PR on the forum thread and a maintainer or staff member will reopen it. |
Thanks! Cross-ref forum post: https://forum.exercism.org/t/wasm-lib-pr-adding-a-general-purpose-console-log-import/8186 |
Hi @Terr, I appreciate the PR! Unfortunately, we can't accept this. I understand that this might be frustrating to you, but I would like to express that it is great that you are trying to give back. I'd like to explain my rationale for why I don't think we should accept this and offer a suggestion for an alternative area to redirect your effort. Why we can't accept this: Your new You might be surprised by this given that you are modeling off the examples on MDN. Looking at the examples there, they only deal with a single instruction and log is only able to log a single type. For example, if you go to https://developer.mozilla.org/en-US/docs/WebAssembly/Reference/Numeric/Subtraction and you replace the WAT in the demo with the following:
you will error out with the following:
You can change the type in the import
And now this seems to work:
There are still some problems here though. For example, signedness.
Both values are logged as signed integers (likely because JS doesn't really support first-class unsigned integers):
Also, how would one log strings? These DX concerns motivated why You mention that "WasmRunner has plenty of alternative logging functions (including log_i32_u() that is also just a console.log() call) but it's not obvious they exist if you don't look into this source file." At least in the web editor, this is not the case. There is a very lengthy "How to debug" section under the "Instructions" section of each problem that describes all of the logging functions, shows examples, and provides a rationale. The markdown that populates this is in the track repo at (https://github.com/exercism/wasm/blob/main/exercises/shared/.docs/debug.md). My suggestion is that we decline this PR and we work to determine how the existing documentation broke down in your workflow / improve the documentation if anything is unclear. Because it's so prominent in the Web editor, I assume you're using the CLI, so that's not surfaced to you? |
Thanks for your extensive reply. I just intended this as a simple addition and I have no idea how to make it work for some of the types you mention, so I guess we should just close this PR. Regarding the documentation bit: I do indeed use the Exercism CLI tool. https://exercism.org/docs/tracks/wasm/learning is the page I got my information from, I truly had no idea the web editor had its own documentation. I don't know if that's also the case on other tracks but it does seem like a waste to not link that more prominently somewhere. |
Please know that even though we didn't merge this, your feedback is extremely helpful! I hadn't realized that there was such a gap between the web UI and the CLI tool. I suspect we may need to add something like a boilerplate comment to the *.wat source file of each exercise linking to the debug markdown file. Have a good remainder of your weekend! |
Many WebAssembly tutorials, including the example code on MDN, use a
"console" "log"
import. I thought it would be good to add this import to avoid confusion when people copy/paste example code into their Exercism exercise.WasmRunner
has plenty of alternative logging functions (includinglog_i32_u()
that is also just aconsole.log()
call) but it's not obvious they exist if you don't look into this source file. And if you're a WASM beginner (like me) you might not even realize that the"console" "log"
import has to be defined somewhere ahead of time.