Blog 7 - Node
What is Node.js?
Node.js is a scalable network application builder that uses an asynchronous event-driven JavaScript engine. Many connections can be handled at the same time in the "hello world" example below. The callback is invoked with each connection, but if there is no work to be done, Node.js will sleep. Node.js is influenced by and similar in design to Ruby's Event Machine and Python's Twisted. The event concept is taken a step further in Node.js. An event loop is presented as a runtime construct rather than a library. In other systems, the event-loop is always started with a blocking call. There is no such start-the-event-loop method in Node.js. Following the execution of the input script, Node.js simply enters the event loop. When there are no more callbacks to execute, Node.js leaves the event loop. The event loop is hidden from the user, much like in browser JavaScript.
In Node.js, HTTP is treated as a first-class citizen, with the goal of allowing streaming and minimal latency. As a result, Node.js is an excellent choice for a web library or framework's base. Despite the fact that Node.js is not built to work with threads, you may nevertheless use many cores in your environment. Our child process.fork() API may be used to spawn child processes, which are meant to be simple to interact with. The cluster module, which is based on the same interface, allows you to share sockets across processes in order to load balance across your cores.
History of Node.JS
Ryan Dahl created Node.js in 2009, around thirteen years after the release of Netscape's LiveWire Pro Web, the first server-side JavaScript environment. Only Linux and Mac OS X were supported at first. Dahl was in charge of its creation and upkeep, while Joyent was eventually a sponsor. Dahl blasted the most popular web server in 2009, Apache HTTP Server, for its limited ability to handle a large number of concurrent connections, as well as the most common method of writing code, in which code either blocked the entire process or implied multiple execution stacks in the case of multiple connections.