Node.js
Encyclopedia
Node.js is a software system
Software system
A software system is a system based on software forming part of a computer system . The term "software system" is often used as a synonym of computer program or software; is related to the application of systems theory approaches in software engineering context and are used to study large and...

 designed for writing highly-scalable
Scalability
In electronics scalability is the ability of a system, network, or process, to handle growing amount of work in a graceful manner or its ability to be enlarged to accommodate that growth...

 internet applications, notably web server
Web server
Web server can refer to either the hardware or the software that helps to deliver content that can be accessed through the Internet....

s.
Programs are written in JavaScript
JavaScript
JavaScript is a prototype-based scripting language that is dynamic, weakly typed and has first-class functions. It is a multi-paradigm language, supporting object-oriented, imperative, and functional programming styles....

, using event-driven, asynchronous I/O
Asynchronous I/O
Asynchronous I/O, or non-blocking I/O, is a form of input/output processing that permits other processing to continue before the transmission has finished....

 to minimize overhead and maximize scalability.
Node.js consists of Google's V8 JavaScript engine
V8 (JavaScript engine)
The Google V8 JavaScript Engine is an open source JavaScript engine developed by Google and ships with the Google Chrome web browser. Lars Bak is the head programmer....

 plus several built-in libraries.

Node.js was created by Ryan Dahl starting in 2009, and its growth is sponsored by Joyent
Joyent
Joyent is a cloud computing software and services company based in San Francisco, California, since 2004. Joyent provides application virtualization....

, his employer.

Similar environments written in other programming languages include Twisted
Twisted (software)
Twisted is an event-driven network programming framework written in Python and licensed under the MIT License.Twisted projects variously support TCP, UDP, SSL/TLS, IP Multicast, Unix domain sockets, a large number of protocols , and much more...

 for Python
Python (programming language)
Python is a general-purpose, high-level programming language whose design philosophy emphasizes code readability. Python claims to "[combine] remarkable power with very clear syntax", and its standard library is large and comprehensive...

, Perl Object Environment
Perl Object Environment
The Perl Object Environment or POE is a library of Perl modules written in the Perl programming language by Rocco Caputo et al.From CPAN:-POE Architecture: Layers of Abstraction :...

 for Perl
Perl
Perl is a high-level, general-purpose, interpreted, dynamic programming language. Perl was originally developed by Larry Wall in 1987 as a general-purpose Unix scripting language to make report processing easier. Since then, it has undergone many changes and revisions and become widely popular...

, libevent
Libevent
libevent is an asynchronous event notification software library.The libevent API provides a mechanism to execute a callback function when a specific event occurs on a file descriptor or after a timeout has been reached. Furthermore, libevent also supports callbacks due to signals or regular...

 for C
C (programming language)
C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system....

 and EventMachine for Ruby
Ruby (programming language)
Ruby is a dynamic, reflective, general-purpose object-oriented programming language that combines syntax inspired by Perl with Smalltalk-like features. Ruby originated in Japan during the mid-1990s and was first developed and designed by Yukihiro "Matz" Matsumoto...

. Unlike most JavaScript
JavaScript
JavaScript is a prototype-based scripting language that is dynamic, weakly typed and has first-class functions. It is a multi-paradigm language, supporting object-oriented, imperative, and functional programming styles....

, it is not executed in a web browser, but is instead a form of server-side JavaScript
Server-side JavaScript
Server-side JavaScript refers to JavaScript that runs on the server-side. This term was coined because the language is predominantly used on the client-side, i.e. client-side JavaScript ....

. Node.js implements some CommonJS
CommonJS
CommonJS is a project with the goal of specifying an ecosystem for JavaScript outside the browser . The project was started by Kevin Dangoor in January 2009 and initially named ServerJS....

 specifications. Unlike most JavaScript systems, it provides a REPL
Read-eval-print loop
A read–eval–print loop , also known as an interactive toplevel, is a simple, interactive computer programming environment. The term is most usually used to refer to a Lisp interactive environment, but can be applied to command line shells and similar environments for F#, Smalltalk, Standard ML,...

 environment for interactive testing.

Examples

This is a complete implementation of hello world
Hello world program
A "Hello world" program is a computer program that outputs "Hello world" on a display device. Because it is typically one of the simplest programs possible in most programming languages, it is by tradition often used to illustrate to beginners the most basic syntax of a programming language, or to...

 as a HTTP Server
Web server
Web server can refer to either the hardware or the software that helps to deliver content that can be accessed through the Internet....

 in Node.js:

var http = require('http');

http.createServer(function (request, response) {
response.writeHead(200, {'Content-Type': 'text/plain'});
response.end('Hello World\n');
}).listen(8000);

console.log('Server running at http://127.0.0.1:8000/');

This is a simple TCP
Transmission Control Protocol
The Transmission Control Protocol is one of the core protocols of the Internet Protocol Suite. TCP is one of the two original components of the suite, complementing the Internet Protocol , and therefore the entire suite is commonly referred to as TCP/IP...

 server which listens on port
TCP and UDP port
In computer networking, a port is an application-specific or process-specific software construct serving as a communications endpoint in a computer's host operating system. A port is associated with an IP address of the host, as well as the type of protocol used for communication...

 7000 and echoes 'hello' upon connection:

var net = require('net');

net.createServer(function (stream) {
stream.write('hello\r\n');

stream.on('end', function {
stream.end('goodbye\r\n');
});

stream.pipe(stream);
}).listen(7000);

Community

Node.js has a active developer community primarily centered on two mailing lists, nodejs and nodejs-dev, and the IRC channel #node.js on freenode
Freenode
freenode, formerly known as Open Projects Network, is an IRC network used to discuss peer-directed projects. Their servers are all accessible from the domain name [irc://chat.freenode.net chat.freenode.net], which load balances connections by using the actual servers in rotation...

. The community gathers at NodeConf, an annual developer conference focused on Node.js.

See also

  • JavaScript
    JavaScript
    JavaScript is a prototype-based scripting language that is dynamic, weakly typed and has first-class functions. It is a multi-paradigm language, supporting object-oriented, imperative, and functional programming styles....

  • V8 (JavaScript engine)
    V8 (JavaScript engine)
    The Google V8 JavaScript Engine is an open source JavaScript engine developed by Google and ships with the Google Chrome web browser. Lars Bak is the head programmer....

  • NPM, the Node Package Manager - the predominant package manager for Node.js. As of Node.js version 0.6.3, npm is installed automatically with Node.js.
  • JSAN
    JSAN
    The JavaScript Archive Network is an on-line collaborative resource to develop Open Source libraries and software for JavaScript. JSAN's aim is to create the JavaScript equivalent of Perl' s CPAN. For example, the module Joose is an equivalent to the CPAN module Moose...

    , the JavaScript Archive Network - a lesser used JavaScript package manager.

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK