Why Was Node.js Written in the C/C++ Programming Language
C/C++ languages were used in writing Node.js, while the V8 JavaScript Engine of Google is used in converting the JavaScript code to C++. V8 Engine is embedded in a Node.js environment, which uses the libuv to deal with asynchronous events. So, it wouldn’t be wrong to say that the Node.js ecosystem is truly dependent on C/C++.
The reason of using C/C++ in Node.js is that C is a procedural programming language and C++ is an object-oriented programming language. Integrating both will help users perform complex coding tasks with high security. Further with C/C++, users can also develop OS-level and hardware-level applications. In addition, the CPU-intensive operations can be run faster in C++ than in JavaScript. Keeping all this in view, C/C++ were the ideal language for Node.js. Moreover, there has been a trend or you can call it a tradition, to design compilers using either C or C++ because of their efficiency. So, the Node.js developers also adopt it.
Why are C/C++ Addons Used in Node.js
Some Node.js add-ons are based on C++, as these add-ons are multiple linked shared objects. By using C++ add-ons, the C++ libraries get support in the Node.js environment, allowing users to even perform complex programming tasks with far better performance. Even for CPU-intensive operations, the performance gets a lot better with C++ addons rather than just using JavaScript.
Conclusion
Node.js is a JavaScript runtime environment which uses Google’s V8 engine to convert JavaScript code to C++. Node.js is written in C/C++ for multiple reasons which include fast running, better performance, direct interaction with the OS, compatibility with the hardware and other such reasons. For Node.js, C/C++ addons are also supported to allow C/C++ libraries to run and allow users to perform different complex operations.