Comments (8)
This is a good point. We do have an article about compiling over from C++: https://developer.mozilla.org/en-US/docs/WebAssembly/C_to_wasm
But there is nowhere where we show direct comparisons between source (e.g. C++) and equivalent WA, along with compilation to wasm and usage in the JS.
Early next year I am intending to add a bunch of information on Rust and it's advantages over C++ in being the source of WAT/WASM. I will make this part of that initiative for sure.
from webassembly-examples.
I actually am putting together an outline for a tutorial with a realistic example: passing a Unicode string from JS to C++-compiled WASM, and passing it back in chunks.
The inspiration is a need I have for a XML parser. I was thinking of compiling Expat in WebAssembly. Before I can do that, I need someone to fill in some gaps on bridging C++ and JS.
So, I want to provide a baseline demo project with very specific questions and a tutorial document outline. I also want to find a colleague who understands WebAssembly well enough to answer those questions and complete writing the tutorial. The tutorial will assume general familiarity with JavaScript and C++.
I would provide:
- Test code in C++ which passes
- Test code in JS which passes (without calling the C++ code)
- A not-insignificant Unicode string to pass around.
- I'm thinking a MathML fragment for the definition of a limit from calculus.
- A Makefile to build the C++ project and to run the test code in C++ and JS
- A partial tutorial document, with complete outline.
The questions I want answered:
- JS code to import the module
- JS code to create an instance of the module's desired WASM class
- Passing a JS callback function into the instance for the C++ code to invoke, with the first argument being an Unicode string
- JS code calling a C++ method of the WASM instance, with an Unicode string
- Excluding void main() from the generated WASM code
- Makefile changes needed to compile the C++ code by em++
- How to migrate comments from C++ to WASM module, if possible
- A configure script to check for a minimal version of em++ (and probably nodejs as well)
Is there anyone out there who could be an effective partner in this?
from webassembly-examples.
There's also a lot of work on ergonomics and integrating into existing ESM/node workflows over in https://rust-lang-nursery.github.io/rust-wasm/. In particular, you can see mentioned in the README.md that one of the goals of that project is a small book documenting the whole workflow and I see a lot of active work on that in my GH notifications.
from webassembly-examples.
I actually am putting together an outline for a tutorial with a realistic example: passing a Unicode string from JS to C++-compiled WASM, and passing it back in chunks.
The inspiration is a need I have for a XML parser. I was thinking of compiling Expat in WebAssembly. Before I can do that, I need someone to fill in some gaps on bridging C++ and JS.
So, I want to provide a baseline demo project with very specific questions and a tutorial document outline. I also want to find a colleague who understands WebAssembly well enough to answer those questions and complete writing the tutorial. The tutorial will assume general familiarity with JavaScript and C++.
I would provide:
Test code in C++ which passes
Test code in JS which passes (without calling the C++ code)
A not-insignificant Unicode string to pass around.
- I'm thinking a MathML fragment for the definition of a limit from calculus.
A Makefile to build the C++ project and to run the test code in C++ and JS
A partial tutorial document, with complete outline.
The questions I want answered:
- JS code to import the module
- JS code to create an instance of the module's desired WASM class
- Passing a JS callback function into the instance for the C++ code to invoke, with the first argument being an Unicode string
- JS code calling a C++ method of the WASM instance, with an Unicode string
- Excluding void main() from the generated WASM code
- Makefile changes needed to compile the C++ code by em++
- How to migrate comments from C++ to WASM module, if possible
- A configure script to check for a minimal version of em++ (and probably nodejs as well)
Is there anyone out there who could be an effective partner in this?
Hi, I was wondering if there was any follow-up?
from webassembly-examples.
No, sorry, life got in the way of my ambitions. Again.
from webassembly-examples.
No, sorry, life got in the way of my ambitions. Again.
May I ask you a question?
I want to know how to receive functions and variables imported from JS in C language. From the tutorial, I can only see how to import functions and variables in wat format, but can not find how to operate in C language
from webassembly-examples.
You'll have to ask someone else. I really haven't done any WebAssembly work at all. This ticket was supposed to be a way into that for me.
from webassembly-examples.
May I ask you a question? I want to know how to receive functions and variables imported from JS in C language. From the tutorial, I can only see how to import functions and variables in wat format, but can not find how to operate in C language
Hey, @HackerWand. if you're still interested in an answer to that: you would use C's extern
keyword before the function, and in emscripten you might need to use their macro before that, EMSCRIPTEN_KEEPALIVE
. But you can always ask for how to do the same of dedicated programming assistance websites, such as stackoverflow.com.
from webassembly-examples.
Related Issues (15)
- How dose "WebAssembly.Memory" work? HOT 4
- Error when compiling wasm-table.wat HOT 1
- please add c/c++ source code of webassembly-examples/js-api-examples/table2.wat HOT 9
- ost
- CODE_OF_CONDUCT.md file missing
- use local.get instead of get_local
- online examples feature wanted
- Provide source code that you used for demos HOT 2
- chore: repository standard
- Nk HOT 1
- #<Module> could not be cloned HOT 7
- TypeError: Incorrect response MIME type. Expected 'application/wasm' HOT 6
- Which format is relevant? HOT 3
- Memory example doesn't show how to pass memory as an import HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from webassembly-examples.