#AIM3

Node.js + Higher Ed = Awesome!


Jim Muir
@jamespaulmuir


 // useTogether.js
 module.exports = function (thing1, thing2) {
	if (thing1 === 'Node.js' && thing2 === 'Higher Ed') {
		return 'Awesome!';
	}
 };

 // app.js
 var useTogether = require('useTogether');

 var nodejs = 'Node.js';
 var higherEd = 'Higher Ed';

 var result = useTogether(nodejs, higherEd);

 assert.equal(result, 'Awesome!');
					

Questions we are going to answer today

  1. What is Node.js?

  2. What's the point?

  3. How do I use it?

  4. How do I convince my boss to use it?

  5. Where can I learn it?

What is Node.js?

Node.js is a platform built on Chrome's JavaScript runtime, V8.

Node.js uses an event-driven, non-blocking I/O model.

Does this look familiar w/your platform?
Node.js

Node.js is Event Driven

Node.js is easy to learn

Node.js Basics

Installer available for Mac/Windows
Source/Binaries available for Mac/Win/Linux
Language: Javascript


(on the server!??)
Ginormous module ecosystem: NPM
Node.js has a built-in HTTP server

Applications of Node.js

websites
web applications
api servers
command-line tools
build systems
robots

Why use it?

Push Notifications Event Driven
Offline data Server and Client-side caching
User Experience Fast
Client Platform Agnostic Android, iOS, ??
Aggregation, validation, and transformation of data Yes
Consistent API output format & error handling Framework
Scalability (80K+ users) High Concurrency
Flexibility of custom integrations Yes

Ohio State

Powers our mobile app

Exposes all the data through a JSON REST API

GET /parking/garages/availability
Uses HTTP-caching (Last-Modified, If-Modified-Since)
Pulls data from various sources around campus and outside
Parses, validates, transforms, and caches data

Consistent output format and error handling for mobile apps
Very fast
High concurrency

New features can be built quickly and easily

A natural framework evolves and makes it very easy to build new features.

Architecture Overview

Data Sync Overview

How do I use node.js?

Developer edition

Getting Started

  • npm
  • gulp
  • express

npm

npm

Not "Node Package Manager", it is a recursive bacronymic abbreviation for "npm is not an acronym"


Node.js comes bundled with npm command line tool


 # install module locally
 npm install lodash
					


 # install module locally and save version info in package.json
 npm install --save lodash
					


 # install module globally
 npm install -g grunt-cli
					

package.json



{
    "name": "reveal.js",
    "version": "2.6.2",
    "description": "The HTML Presentation Framework",
    "engines": {
        "node": "~0.8.0"
    },
    "dependencies": {
        "underscore": "~1.5.1",
        "express": "~2.5.9",
        "mustache": "~0.7.2",
        "socket.io": "~0.9.13"
    },
    "devDependencies": {
        "gulp": "^3.7.0"
    }
}

					

Gulp

gulp.js - The streaming build system

Similar to Rake, Make, ant, Grunt


Gulp is quickly dethroning Grunt as the defacto build platform for Node and non-node projects.

Gulp can run any Grunt task

What does Gulp do?

There are over 700 gulp plugins as well as access to over 3,000 Grunt plugins

  • Watch - will watch for changes in files and perform tasks
  • Copy, Clean, Concat, Compress
  • Less/Sass/Compass/Stylus compile
  • Uglify
  • Run tests
  • JSLint/JSHint
  • Compile Handlebars/Jade templates
  • Compile/Map Coffeescript
  • Generate documentation
  • Livereload - reload assets/templates live in the browser as you make changes

Express

Express is a web framework for Node.js

  npm install --save express
				

Handles things such as:

  • Routing
  • Sessions
  • Parsing the request body
  • Compression (gzip)
  • Serving static files (css, images, js)
  • Error handling

How do I use node.js?

Infrastructure Professional edition

Node.js can run on pretty much any platform.
If you happen to use RHEL/CentOS, you can simply run:

sudo yum install npm
				
It's a good idea to have a process "watch" node, manage restarts, and keep it running smoothly

 npm install -g forever
				
Node runs its own HTTP server

# Apache
ProxyPass / http://localhost:1337
ProxyPassReverse / http://localhost:1337
				

Make sure your developer is using domains to catch exceptions that bubble up.


Otherwise node process will crash

Convince your boss guide

Do your research, make sure Node.js is a good fit for the application.
Tell your boss that Gartner likes Node.js.
Most web developers already know Javascript.
There's a module for pretty much anything you can think of

If all else fails, tell your boss who else is using Node.js...

LinkedIn

Node.js powers entire mobile experience

Flickr

Using node.js (and Redis) to drive push notifications

eBay

ql.io, a declarative, evented, data-retrieval and aggregation gateway for HTTP APIs

Dow Jones

WSJ Mobile, Portfolio, Streaming Stories, DJ X, and many other tools and services at Dow Jones run completely on node


Palm/HP

powers all the services in the WebOS platform for mobile devices.


Countly

Open source, real-time mobile analytics platform that runs on MongoDB and Node.js


Rdio

Uses node to synchronize state across multiple devices logged in to a single account, render pages for non-JS browsers.


Voxer

Walkie Talkie for your iOS device, backend uses all kinds of node


Storify.com

is an entirely Node.js based platform.


Yahoo!

Node.js is the basis of Yahoo! Manhattan, part of the"Cocktails platform


Microsoft

Core contributor to node.js for Windows. Uses node.js internally and provides cloud hosting for node.js applications in Windows Azure.

Shutterstock

Over 20 million stock photos, illustrations, vectors, and videos.


Yammer

The Yammer Application Platform heavily uses node.js


Trello

single-page web app collaboration tool from Fog Creek


Cloud9

Cloud9 IDE is aiming to be the IDE for Javascript developers, built with NodeJS and lots of other Node modules

Feedhenry

uses node to host server-side JS for mobile apps in a MEAP (Mobile Enterprise Application Platform)



Kinvey

A Backend as a Service platform that makes really easy for developers to setup and operate backends for mobile, tablet AND web apps.

Paypal

“ We are moving every product & every site within PayPal to Node. We started the journey by using it as prototyping framework, then at start of this year we hardened it to work with all PayPal systems. We have several of our beta products out live on NodeJS and half dozen other products in flight. By end of 2014 we hope to have all major experiences redesigned, and rewritten on nodejs... ”


‐ Bill Scott
Sr. Director UI Engineering at PayPal

Paypal

“ NodeJS is a forcing function to completely obliterate the old stack and the old experiences.

We are seeing big scale gains, performance boosts and big developer productivity ”


‐ Bill Scott
Sr. Director UI Engineering at PayPal

Others

Joyent, Klout, 37Signals, The Ohio State University

Where can I learn Node.js?

Nodeschool

http://nodeschool.io/

The Art of Node

So why should I use Node.js?

Jim's list of Node.js pros

Javascript is a powerful language
High performance/scalable
Developer happiness/productivity
There's a module for pretty much anything you can think of
Developer community is very prolific and is growing
Node.js is well documented
Event-driven programming is can be fun
Application structure is completely flexible, not locked into conventions

THE END

Questions?