Reputation: 53
So the async programming in client-side javascript is that the setTimeOut is ran in the browser API so it doesn't block javascript single thread. Since we don't have the browser API in Node, who runs the async part of the code? C or C++?
Upvotes: 1
Views: 58
Reputation: 708106
First off, node.js consists of a runtime environment that includes the V8 Javascript engine, a cross platform library (written in C/C++) that includes the event loop) which is called libuv
and then a library full of all sorts of add-on functions that are not part of the standard Javascript definition for doing networking, crypto, file system access and so on. Many of these library functions are written in a combination of Javascript and C++.
The asynchronous operations in node.js are all from the nodejs runtime library written in C/C++. This includes all sorts of things such as setTimeout()
, the entire fs
library for accessing files, the net
library for doing networking, etc...
Upvotes: 1