George Ornbo @shapeshed
Hackference, Birmingham 30th August 2013
- HTML born
- Databases and scripting languages
- APIs
- Ajax
- Web Standards
- JavaScript
- Everything is networked
- Everything is connected all the time
- Everyone has superpowers in their pockets
- More wearable (and embeddable?) tech to come
- We have an amazing platform to hack on
- Browsers
- Databases
- File Systems
- Networks
- PRINT 10 'YOU ARE IN A ROOM'
- Chess
- Street Fighter
- MMORPG
- Total mania
- HTTP 1.1
- WebSockets, SSE
- Crappy browsers (still)
- Events
- An example from the browser
$('p').hide('slow');
alert("The paragraph is now hidden");
$('p').hide('slow', function() {
alert("The paragraph is now hidden");
});
- An example on the server
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello Hackference!\n');
}).listen(3000, "127.0.0.1");
- JavaScript API into C++ bindings to V8
- Created by Ryan Dahl
- V8 is Chrome's JavaScript Engine
- Small core, big userland
- UNIX philosophy of doing one thing well
- Software
- Quick HTML Prototypes
- REST APIs
- Realtime
- Data-streaming
- Hardware
- Arduinos
- Quadcopters
- Serial Ports
- Package manager
- npm install foo
- npm publish
- For client-side too (with bower)
- Grunt
- JSHint
- grunt-* tools
- Testing
- Building
- Washing your car. Bucket or hose.
- Using data when it is ready
- API stabilising
- Most things in node are a stream
var fs = require('fs');
var stream = fs.ReadStream('enormous.txt');
stream.setEncoding('utf8');
stream.on('data', function(chunk) {
console.log('read some data')
});
stream.on('close', function () {
console.log('we are done')
});
- Like UNIX you can pipe
var http = require('http'),
fs = require('fs');
http.createServer(function(request, response) {
var mp3 = 'birdie-song.mp3';
var stat = fs.statSync(mp3);
response.writeHead(200, {
'Content-Type': 'audio/mpeg',
'Content-Length': stat.size
});
var readableStream = fs.createReadStream(mp3);
readableStream.pipe(response);
}).listen(3000);
- The server and the application are one process
- Self-hosting can be tricky
- Heroku and Nodejitsu offer free hosting
- There isn't a Rails equivalent in node.js
- Callbacks
- CoffeeScript
- eBay
- Yahoo
- Voxer
- Start with Express
- IRC, Mailing lists, blog posts
- Books
- But most of all hack!
- Andrew likes bunnies
- Andrew makes a mean chocoloate brownie
- Andrew organises LNUG and The Great British Node Conf
- He has drones!