Node.js

From Wikipedia, the free encyclopedia
Jump to: navigation, search
Node.js
Node.js Logo
Original author(s) Ryan Lienhart Dahl
Developer(s) Node.js Developers, Joyent
Stable release 0.8.18 / January 18, 2013; 9 days ago (2013-01-18)
Preview release 0.9.8 / January 24, 2013; 3 days ago (2013-01-24)
Development status Active
Written in C++, JavaScript
Operating system Mac OS X, Linux, Solaris, FreeBSD, OpenBSD, Windows (older versions require Cygwin), webOS
Type Event-driven networking
License MIT License
Website nodejs.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]

Contents

[edit] 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 growth 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 Twisted for Python, Perl Object Environment for Perl, libevent for C, Vert.x for Java and EventMachine for Ruby. 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 provides a REPL environment for interactive testing.

[edit] 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 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);

[edit] Community

Node.js has a developer community primarily centered around 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] Yahoo![11] and Walmart.[12]

[edit] 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

[edit] 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. http://www.theregister.co.uk/2011/03/01/the_rise_and_rise_of_node_dot_js/.
  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. http://www.sdtimes.com/NODE_JS_PUSHES_JAVASCRIPT_TO_THE_SERVER_SIDE/By_Alex_Handy/About_JAVASCRIPT_and_NODEJS/35668. 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. http://venturebeat.com/2012/05/02/linkedin-ipad-app-engineering/. 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. http://www.guardian.co.uk/technology/blog/2011/nov/09/programming-microsoft. Retrieved May 10, 2012.
  11. ^ [2], Yahoo! Developer Network announces Cocktails project using Node.js
  12. ^ "Why Walmart is using Node.js". VentureBeat. January 24, 2012. http://venturebeat.com/2012/01/24/why-walmart-is-using-node-js/. Retrieved May 10, 2012.

[edit] Further reading

[edit] External links