
Getting into Node | On the JVM Updated 2011-04-27: forgot to add Backbone.js Most of the net is abuzz about Node , so it’s hard to miss it. I’ve been sitting on the sidelines for several months now, but after attending a TechTalksTO talk on Node given by James Duncan of Joyent, I’m convinced I should dive in. tl;dr version Like C, Javascript is here to stay. What is Node? Node is a server side Javascript implementation. To make full use of this fast underpinning, Node follows a non-blocking, fully asynchronous programming mode, and encourages libraries to follow its example. Why Node and Not Another Server Side Javascript? The best known server side Javascript implementation is Rhino. Are there any fast alternatives to Rhino on JVM? Most of the server side Javascript implementations didn’t grasp the importance of non-blocking, asynchronous I/O. Why Asynchronous? Asynchronous programming is usually associated with GUI development where everything is event driven and asynchronous. That’s why you want non-blocking I/O. Then run
An Absolute Beginner's Guide to Node.js There's no shortage of Node.js tutorials out there, but most of them cover specific use cases or topics that only apply when you've already got Node up and running. I see comments every once and awhile that sound something like, "I've downloaded Node, now what?" This tutorial answers that question and explains how to get started from the very beginning. What is Node.js? A lot of the confusion for newcomers to Node is misunderstanding exactly what it is. An important thing to realize is that Node is not a webserver. Installing Node Node.js is very easy to install. I've Installed Node, now what? Once installed you'll have access to a new command called "node". $ node > console.log('Hello World'); Hello World undefined In the above example I typed "console.log('Hello World')" into the shell and hit enter. The other way to run Node is by providing it a JavaScript file to execute. hello.js console.log('Hello World'); $ node hello.js Hello World Doing Something Useful - File I/O example_log.txt
node.js beginner tutorials Felix's Node.js Convincing the boss guide « Home / All Guides Now that you're all hyped up about using node.js, it's time to convince your boss. Well, maybe. I have had the pleasure of consulting for different businesses on whether node.js is the right technology, and sometimes the answer is simply no. So this guide is my opinionated collection of advice for those of you that want to explore whether node.js makes sense for their business, and if so, how to convince the management. Bad Use Cases CPU heavy apps Even though I love node.js, there are several use cases where it simply doesn't make sense. That being said, node.js allows you to easily write C++ addons, so you could certainly use it as a scripting engine on top of your super-secret algorithms. Simple CRUD / HTML apps While node.js will eventually be a fun tool for writing all kinds of web applications, you shouldn't expect it to provide you with more benefits than PHP, Ruby or Python at this point. NoSQL + Node.js + Buzzword Bullshit Good Use Cases JSON APIs Single page apps
The Node Beginner Book » A comprehensive Node.js tutorial How To Node - NodeJS Max Ogden Blogotronz Description of and notes on the node.js Stream API There is also a screencast version of this article. node bills itself as JavaScript evented I/O. In a nutshell that means if you are trying to solve a problem that is I/O bound (the limiting factor is reading/writing to relatively slow interfaces) then node can provide some useful abstractions to you. "Streams in node are one of the rare occasions when doing something the fast way is actually easier. -@dominictarr in his high level node style guide The main tool in node's evented toolbox is the Stream. Readable Readable streams will emit data events each time they get a "chunk" of data and then they will emit end when they are all finished. emit (from EventEmitter) is the observer pattern - a publish/subscribe pattern which allows a number of observer objects to see an event. Readable streams can also be paused and resumed, and it's up to the Stream implementer to write the pause() and resume() methods. Writable Simplified writable stream
Best practices of building a website using node.js nodeapps/http-server Update on my Node.js Memory and GC Benchmark - Hannes Wallnöfer Posted on 29 September 2010 I was lucky enough to have a short chat with Ryan at JSConf.eu last weekend in Berlin about the memory allocation comparison between Node.js and RingoJS I had done. He didn’t have any suggestion for tuning Node.js or V8 for higher memory and garbage collector throughput, but thought it was possible that Node’s lackluster performance in the benchmark had to do with binary buffers and getting data in and out of them. Thinking about a memory and garbage collection benchmark that didn’t involve buffers quickly led me to JSON. Here’s the source code of the JSON parsing benchmark I wrote. The results I got confirmed those of the other benchmarks, with Node.js scoring 613 requests per second and RingoJS 1123 (this result was updated from the original post, see notes below). My original concusion was to blame the V8’s garbage collector for not being tuned to deal with the workload generated by my benchmarks. Notes
node.js - Loading basic HTML in NodeJS My Node.js Linksheet - Progstr Filer Recently I have been looking around the internet for various info about Node.js. At first, my intent was to make some sort of infographic on the topic, but later I have changed my mind. I like infographics a lot, but they have an important limitation - their links aren't clickable. That is why I have decided to simply categorize the information and share it. Hopefully, someone will benefit from that. Some companies, using Node.js 37Signals.com use Node.js to write Pow, zero configuration Rack server for OS/X. academia.edu uses Node for background data processing. appendto.com Dow Jones - The WSJ Social front-end is written completely in node, using Express, ejs, and many other modules. duckduckgo.com uses it for XMPP bot im@ddg.gg. ebay.com uses Node.js in ql.io An HTTP gateway. ge.tt is a file sharing service. heroku.com use Node for internal tools. joyent.com is the basic supporter of Node.js. klout.com livechat.com Telefónica R&D Yahoo! c9.io - full server-side stack runs on Node.js. #node.js
Getting started with node.js A simple, standardised way of providing Javascript libraries. Define methods to make available to the world using exports. Import modules using require. In a previous slide I mentionded that node.js is easily extensible because it makes use of CommonJS. So what's that? CommonJS is an attempt to expand the standard library provided by the Javascript specification into something that is useful beyond the browser-based world that Javascript is normally confined to. This code example shows how CommonJS can be used. require is a construct used to import Javascript modules. There are other built-in modules for handling things like file I/O (the POSIX module), HTTP servers (there's a server and a client implementation in the HTTP module), generic TCP servers (the TCP module), DNS lookups (the DNS module) and several others. To write your own you define properties on the exports object which are then returned from a require() on that file.
anode@microsoft