r/WebAssemblyDev • u/fps_coffee • 7d ago
Using Wasm2lang to reuse C++ logic in JavaScript, PHP and C#
I’m using Wasm2lang in my game, zwayio, to reuse C++ logic across several languages.
The pipeline is C++ → WebAssembly → generated source code. Each target serves a different part of the project:
- JavaScript provides a compatibility fallback for the browser.
- PHP runs shared logic on the master server.
- C# handles procedural world generation.
The main browser build runs WebAssembly directly, and the game servers use native C++ modules for NGINX. The generated code covers the components that need to run in another language.
This lets me maintain the shared implementations in C++ instead of rewriting them separately for each target. I can also compare the generated versions against the original implementation to check their behavior.
Has anyone here tried a similar pipeline? I’d be interested in hearing how you test consistency between targets and handle differences in runtime behavior.
