Jump to content

Node.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by 77.169.5.103 (talk) at 14:06, 27 April 2013 (Details: The library is called libuv, not libUV.). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Node.js
Original author(s)Ryan Lienhart Dahl
Developer(s)Node.js Developers, Joyent
Stable release
0.10.5 / April 23, 2013 (2013-04-23)
Preview release
0.11.1 / April 19, 2013 (2013-04-19)
Repository
Written inC++, JavaScript
Operating systemMac OS X, Linux, Solaris, FreeBSD, OpenBSD, Windows (older versions require Cygwin), webOS
TypeEvent-driven networking
LicenseMIT License
Websitenodejs.org

Node.js is a server-side software system designed for writing scalable Internet applications, notably web servers.[1] Programs are written on the server side in JavaScript, using event-driven, asynchronous I/O to minimize overhead and maximize scalability.[2]

Node.js creates a web server by itself, making it unnecessary to use web server software such as Apache or Lighttpd and allowing full control of how the web server actually works. Node.js enables web developers to create an entire web application on both server-side and client-side in one language (JavaScript).

Details

Node.js is a packaged compilation of Google's V8 JavaScript engine, the libuv platform abstraction layer, and a core library, which is itself primarily written in JavaScript.

Node.js was created by Ryan Dahl starting in 2009, and its development and maintenance is sponsored by Joyent, his former employer.[3][4]

Dahl's original goal was to create web sites with push capabilities as seen in web applications like Gmail. After trying solutions in several other programming languages he chose JavaScript because of the lack of an existing I/O API. This allowed him to define a convention of non-blocking, event-driven I/O.[5]

Similar environments written in other programming languages include Tornado and Twisted for Python, Perl Object Environment for Perl, libevent for C, Vert.x for Java, Akka for Java and Scala, EventMachine for Ruby and vibe.d for D. Unlike most JavaScript programs, it is not executed in a web browser, but instead as a server-side JavaScript application. Node.js implements some CommonJS specifications.[6] It also provides a REPL environment for interactive testing.

Examples

This is a complete implementation of hello world as an HTTP server 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://localhost:8000/');

The following code is a simple TCP server which listens on port 8000 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(8000);

Tools and IDEs

  • CloudIDE c9.io (cloud service)
  • JetBrains WebStorm or IntelliJ IDEA (commercial products)
  • Microsoft WebMatrix (free) or Visual Studio (commercial product)
  • Netbeans has a NodeJS plugin
  • Nodeclipse (Nodeclipse-1 Eclipse plugin, Eclipse Node.js IDE aka Enide)

Community

Node.js has a developer community primarily centered on two mailing lists, nodejs and nodejs-dev, and the IRC channel #node.js on freenode. The community gathers at NodeConf, an annual developer conference focused on Node.js.[7]

Node.js is currently used by a number of large companies including LinkedIn,[8][9] Microsoft,[10][11] Yahoo![12] and Walmart.[13]

See also

  • npm – the predominant package manager for Node.js. As of Node.js version 0.6.3, npm is installed automatically with Node.js

References

  1. ^ Wait, What's Node.js Good for Again?, By Klint Finley, January 25, 2011, ReadWriteHack
  2. ^ Cade Metz (1 March 2011). "The Node Ahead: JavaScript leaps from browser into future". The Register. {{cite news}}: Italic or bold markup not allowed in: |publisher= (help)
  3. ^ Why Everyone Is Talking About Node, By Jolie O'Dell, March 10, 2011, Mashable
  4. ^ Alex Handy (2011-06-24). "Node.js pushes JavaScript to the server-side". SDTimes. Retrieved 2011-09-04.
  5. ^ Hughes-Croucher, Tom; Wilson, Mike (2012). Up and Running with Node.js. Up and Running (1st ed.). Sebastopol: O'Reilly. p. vii. ISBN 978-1-4493-9858-3. I was concerned about the ability to program advanced push features into the website like I had seen in Gmail
    See the book's Foreword at OReilly.com
  6. ^ Implementations/node.js - CommonJS Spec Wiki
  7. ^ NodeConf Schedule Announced, By Klint Finley, April 7, 2011, ReadWriteHack
  8. ^ "You'll never believe how LinkedIn built its new iPad app". VentureBeat. May 2, 2012. Retrieved May 10, 2012.
  9. ^ [1], LinkedIn's developer blog discusses their Node.js stack optimizations
  10. ^ "Here's why you should be happy that Microsoft is embracing Node.js". The Guardian. November 9, 2011. Retrieved May 10, 2012.
  11. ^ [2], WebMatrix - Front End Web Developers take note (ASP.NET, PHP, node.js and more)
  12. ^ [3], Yahoo! Developer Network announces Cocktails project using Node.js
  13. ^ "Why Walmart is using Node.js". VentureBeat. January 24, 2012. Retrieved May 10, 2012.

Further reading