Ask HN: Transpiling a C lib to use in Electron app?

2 points by epx ↗ HN
Many years ago, I worked on a C library [0] that implements the IEEE 11073:20601 protocol stack. It was a mistake to implement in C, but it was a sponsor requirement back in 2010.

Now, some folks have an Electron app that needs to talk with a 20601-compatible device, and asked for help.

Apart from encapsulating the C code in a subprocess or in a Node.js module, I was wondering if it would be practical to transpile the lib into Javascript. That would spare the app from native code, platform-dependent build settings, crashes, etc.

[0] https://github.com/signove/antidote

2 comments

[ 2.7 ms ] story [ 18.8 ms ] thread
You could always try using Emscripten [0] to generate Javascript from the existing C library and see how that turns out. However, I feel like it could introduce a lot of potential issues.

[0] http://kripken.github.io/emscripten-site/

yep, would also try emscripten which transpiles c to js code. I think it maybe nowadays you can also transpile with the same method from c to WebAssembly which is "native" code essentially.