|
|
|
|
|
by iainmerrick
1932 days ago
|
|
I realise it works, I just don’t think it’s really useful for what was asked for, a way to write common cross-platform business logic for a platform-specific UI. Unless there are some great new tools I’m not aware of, C on WebAssembly seems about the same as C on Android. You can compile stuff just fine, and run it, but actually connecting it up to any substantial UI written in JS/Java is going to be incredibly tedious. For a computation library with well-defined inputs and outputs, and that “just works” and doesn’t need any debugging in situ, it makes a lot of sense. But I think business logic by definition is going to need a much richer interaction with the UI, and that’s what makes it hard. |
|
With Emscripten, you can embed Javascript source code directly into the C code and then call the embedded JS function from the C side as well as C functions from inside Javascript.
E.g. JS embedded in C code:
https://github.com/floooh/sokol/blob/4c56a2ee15d81cac91b738b...
...called from C:
https://github.com/floooh/sokol/blob/4c56a2ee15d81cac91b738b...
...and a C function:
https://github.com/floooh/sokol/blob/4c56a2ee15d81cac91b738b...
...called from a JS function embedded in the C code:
https://github.com/floooh/sokol/blob/4c56a2ee15d81cac91b738b...