This post is my basic answer to the question:
What is NodeJS?
Here I briefly discuss a few things about NodeJS that I think are essential to understanding what NodeJS is as a programming language. This explanation is neither totally comprehensive nor highly detailed.
Event-driven programming is the idea that events control of the flow of a program. When an event occurs, code registered to handle the event is executed. When performing I/O, traditional programming is synchronous, meaning that an executing thread must wait for the I/O operation to complete before it can continue its execution. Solutions such as multi-threading were devised in order to improve CPU productivity by switching between threads when a thread blocks. Multi-threading does however introduce the overhead of switching between threads and remembering each thread’s context.
At the heart of NodeJS is an event loop that performs two tasks: Check to see if an event has occurred and if so, execute the registered event handler. This allows NodeJS to maintain a single thread that is constantly working, executing event handlers as events occur.
NodeJS Module System
NodeJS does away with the global namespace and implements the CommonJS standard. Files and modules have a one-to-one relationship. Each file chooses exactly what will be publicly exposed by the file’s module when it is loaded by other modules. NodeJS looks for core modules first, then modules with relative path names, and finally looks in “./node_modules” when searching for modules. Each module is cached the first time it is loaded, so the contents of each module are only initialized once.
The NodeJS core library provides the developer with a number of tools for performing I/O, working with HTTP, files, the OS, streams, and much more. In addition, npmjs.org is a large repository of community and open source packages for NodeJS. NodeJS is at home in small, rapidly developing products, probably because NodeJS and its ecosystem are still (relatively) small and under rapid development.
Try it! It’s rediculously easy to get started and hard to drop once you get going.