Node.js

From Wikipedia, the free encyclopedia
  (Redirected from Nodejs)
Jump to: navigation, search
Node.js
Node.js Logo
Original author(s) Ryan Lienhart Dahl
Developer(s) Node.js Developers, Joyent
Stable release 0.10.7 / May 17, 2013 (2013-05-17)
Preview release 0.11.2 / May 13, 2013 (2013-05-13)
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]

Node.js contains a built-in HTTP server library, making it possible to run a web server without the use of external software, such as Apache or Lighttpd, and allowing more control of how the web server works. Node.js enables web developers to create an entire web application in JavaScript, both server-side and client-side.

Contents

Details [edit]

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

This is an implementation of a "hello world" 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 [edit]

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

Community [edit]

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

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

References [edit]

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

External links [edit]