-
Notifications
You must be signed in to change notification settings - Fork 2
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
High-level goals? #2
Comments
Hi! Compiling directly to WASM doesn't have clear perfomance advantages over C->WAsm, but as you mention, this allows for a very simplified build process, and it is one of the reasons I started this, to see if it was possible to build wasm directly without clang, emscripten, binaryen, etc. . With my branch, you only need to build nim, so a C compiler (to build nim from sources) is all that is needed. A direct wasm backend also allows for simple interoperability with js, eg importing a function proc log[T](x:T) {.header:"glue", importc:"log".} where glue: {
log: function(arg){
console.log(arg)
},
...
} and we can also have nim run the module with nodejs simply by Exporting to js is even simpler, as a proc with the export marker is automatically exported and calling it from js is as simple as $file.exports.procName(args) File size should also be smaller (at a similar level of features, this project is obviously still too WIP to have a meaningful comparison), as it does not need to compile the C layer, and nim is good at dead code elimination, so only the parts actually used end up in the binary. In the future, having a direct wasm backend also allow for nim specific optimizations, for example once wasm gets gc primitives, or when nim moves to This backend also uses a different way to produce the output code, compared to other nim backends. Instead of appending to a string representation of the code, I produce something similar to an AST for wasm that then gets translated to binary wasm, which I believe could be useful also as a "model" for a new c or js backend, as NimAST->TargetAST transformations feel cleaner and less error prone than NimAST->string. (Sorry about the length of this reply, I got a bit carried away. I hope I answered your question) TL;DR: No clear advantage (for now) aside from easy interoperability with js and build process, project started mostly "for fun". |
I'm interested in this project, but relatively green, so I have an embarrassingly basic question: what advantages does a WASM backend for Nim present versus, e.g., compiling from Nim to C and to WASM through Enscripten (aside from a simpler build process)? Are there features that don't work through that build process currently? Performance concerns? Something else?
Thanks for your patience.
The text was updated successfully, but these errors were encountered: