Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How is nodejs different from running libevent?

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?

like image 642
Mohit Avatar asked Mar 17 '11 00:03

Mohit


People also ask

What makes nodejs different?

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.

Is event loop part of JavaScript or nodejs?

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.

What is the difference between nodejs and node?

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 .

Is JavaScript event loop and node js event loop same?

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.


1 Answers

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.

like image 174
jterrace Avatar answered Sep 29 '22 07:09

jterrace