I've open sourced a JavaScript to WASM compiler. It's an experimental tool, but given the semantics I already implemented, I'm fairly certain I am able to eventually cover 100% of JavaScript spec. Any ideas, questions or critique welcomed! If you are interested in WASM, especially with new proposals like WASM GC or exception handling, it might be a good source of seeing these features in action - the project has a few thousand lines of hand written WAT so far.
Really clever use of the new WASM GC proposal. All the JS -> WASM compilers so far have basically just been shipping a whole JS engine - this is the first one I've seen that actually tries to map JS constructs directly to WASM primitives.
Back in the day I did an almost-Typescript (though much closer than assembly script) to embedded ARM compiler. Some of the techniques may be useful.<p><a href="https://www.microsoft.com/en-us/research/uploads/prod/2019/09/static-typescript-draft2.pdf" rel="nofollow">https://www.microsoft.com/en-us/research/uploads/prod/2019/0...</a>
> As much as I love writing Rust, I also know it's not a widely popular language<p>Is this true? Rust is hyped like crazy and seems to be used everywhere these days.
> I'm fairly certain I am able to eventually cover 100% of JavaScript spec. Any ideas, questions or critique welcomed!<p>Do you have the results of test262_runner.rb? I came to know about test262 at a talk by the porffor's author and something like <a href="https://github.com/CanadaHonk/porffor?tab=readme-ov-file#test262">https://github.com/CanadaHonk/porffor?tab=readme-ov-file#tes...</a> in README would be great to show this progress. Great project by the way!
I read the README.md of the project but I'm still not sure: What's the expected usage of this? How does the outputed WASM code then interacts with a runtime (and with which, is it intended to be a tool compatible with browsers and other WASM runtimes or is it only compatible with a runtime linked to the project)?<p>Somewhat linked questions: How does it react if it encounters e.g. web APIs inside the JavaScript code or other global identifiers only defined in some environment (e.g. a recent browser, Node.js etc.)?
Or if it's not intended for those environments, how are you supposed to do I/O when using this?
I really like this approach. Building for WASM directly, rather than trying to also directly generate binaries, means you can rely on WASM GC and the async support that (I think?) is supposed to be part of WASI 0.3.
How are string encoding discrepancies and related utilities dealt with? My vague understanding is that WASM supports UTF-8 while JS supports (potentially malformed) UTF-16
Title might need to include "Show HN".<p>Very cool and interesting project! How are build times? And how big are the artifacts?<p>I'll for sure keep an eye on this, and add it to my ever expanding list of tech to explore.<p>Thank you for sharing!