4 ms·
Native code has two benefits over JavaScript: it's faster, and it can call the OS. WASM is faster, but it can't call the OS. It cannot replace all uses of nat
by electroly 8y ago
Native code has two benefits over JavaScript: it's faster, and it can call the OS. WASM is faster, but it can't call the OS. It cannot replace all uses of native modules.
- mixedCase 8y agoWasm on the browser can't call the OS, but I don't assume that to be the case on Node, just like it isn't for JS.
- mhenr18 8y agoJS (and eventually wasm) calls the OS via requiring native modules, which is why we're concerned about keeping them around.
- zeroname 8y agoCalling the OS doesn't require native modules, it should be supported via a native cffi in node, like in Python.
- electroly 8y agoAre you describing something you wish that node had, or something that actually exists? As far as I'm aware, native modules are the FFI for node, and that every package that involves presenting an FFI to the developer is using a native module to do it.
- zeroname 8y agoNode doesn't have it natively like Python does, but it exists: https://github.com/node-ffi/node-ffi https://github.com/node-ffi/node-ffi
- electroly 8y agoYeah, that's a native module. If you look at the C source code in "src", the "NAN_METHOD" and stuff are Node native module macros. node-ffi will not work if they remove native modules.