I am curious what gives nodeJS the super concurrency that it gets right now. I have not actually used with either of these that much, just played with both in my spare time.
Sounds like the 1000s of connections that node promises that you can set it up with, you can do that even with libevent, say in C++, no?
Node. js is different from existing server-side frameworks because it is based on asynchronous events via JavaScript callback functionality and uses the JavaScript as a programming language. Moreover, everything inside Node. js runs in single thread.
The event loop is what allows Node. js to perform non-blocking I/O operations — despite the fact that JavaScript is single-threaded — by offloading operations to the system kernel whenever possible. Since most modern kernels are multi-threaded, they can handle multiple operations executing in the background.
The package node is not related to node. js. nodejs is what you want, however it is arguably better to have the command be called node for compatibility with scripts that use #!/usr/bin/env node .
Event loop in Node Js has different phases which has FIFO queue of callbacks to execute. When event loop enters a given phase it operates callbacks in that phase queue until the queue has been exhausted and maximum number of callbacks has executed and then moves to next phase.
Sure you could. In fact, node.js is implemented using libev which is an event library similar to libevent. I think the main advantage of node.js over rolling your own event-driven server in C++ is that it's really easy to use and really easy to get a server up and running quickly without having to write all of the event-based details yourself.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With