Typical use cases for native extensions are WebSockets, WebRTC, Encryptions, Image Processing, Video encodings, native notifications and systray integrations, etc. Or basically, everything which is available only via FFI.
I saw a native extension which calculates the size of a given file by bypassing Node.js super fast file access and using an own implementation. Maybe they did this, or it is necessary for some projects running on a particular OS and or individual file system. Maybe it needs to lock the file exclusively while counting its size. Nevermind, everything is possible, but not everything is necessary.
The pros are integration and sometimes performance.
The cons are restricting usage.
A native extension written for Ubuntu may not perform well when compiled and execute on CentOS. A native extension for Linux may never compile on Windows.
It can be good to learn some C/C++ and write some native extensions. It also enables you to contribute to Node.js core :-)
I didn't mean it the negative way. And yes it can help, but it's not necessary to know C/C++ that much to learn and understand about the internals of Node.js. I learn much more from studying the discussions around each PR on Github :-)
But the commit guide for Node.js core is clean. GitHub and GitKraken showing perfectly what changed. I get a good impression of what's going on even without knowing much C/C++. But I'm not following every aspect or domain. I disable notifications for many PR discussions to keep my inbox clean ;-)
Denny Trebbin
Lead Fullstack Developer. Experimenting with bleeding-edge tech. Irregularly DJ. Hobby drone pilot. Amateur photographer.
Yes, it is. But not in all situations.
Typical use cases for native extensions are WebSockets, WebRTC, Encryptions, Image Processing, Video encodings, native notifications and systray integrations, etc. Or basically, everything which is available only via FFI.
I saw a native extension which calculates the size of a given file by bypassing Node.js super fast file access and using an own implementation. Maybe they did this, or it is necessary for some projects running on a particular OS and or individual file system. Maybe it needs to lock the file exclusively while counting its size. Nevermind, everything is possible, but not everything is necessary.
It can be good to learn some C/C++ and write some native extensions. It also enables you to contribute to Node.js core :-)