6 ms·
Wait, so you compile a swift executable that’s callable from js? How would one distribute this client side in browser? I’m not smart enough to understand this.
by anonymouse008 2y ago
Wait, so you compile a swift executable that’s callable from js? How would one distribute this client side in browser?
I’m not smart enough to understand this. I love swift, vapor and node individually, I don’t get it together
- wk_end 2y agoNode’s a server-side thing, so I don’t think you’d distribute these in the browser.
- vips7L 2y agoIt's a desktop thing too when working with cli tools or electron, though I've found that for electron I just end up calling other languages via IPC on stdin/out. It might not be as fast as ffi from node, but its certainly leagues easier and clearer.
- robmccoll 2y agoYou wouldn't run this in the browser. On the frontend, this would be useful for Electron apps (which run an embedded Chromium for the UI and a local node server for business logic and interfacing with the operating system) on MacOS. On the backend, this might be useful if you have a node-based API and want to share some Swift code between your iOS frontend and node backend.
- brailsafe 2y agoIt might be possible to compile it to web assembly and then call it in the browser.
- demondemidi 2y agoOther way round. NodeJS has had FFI for over a decade that allows you to call functions in .dylib/.a/.dll on Mac/Linux/Windows. I've used it extensively to link with libraries provided by USB device manufacturers to avoid direct USB interfacing. See: https://www.npmjs.com/package/ffi https://www.npmjs.com/package/ffi This let's you call Node from inside Swift.