convince bosses and clients

Today's topics

  1. What is Node.js ?
  2. Is there any success story ?
  3. Making the good choices when starting a project

Vladimir de Turckheim

  • Software engineer @ Steamulo
  • Former cyber-security consultant
  • JavaScript full stack engineer
  • DevOps
  • Open-Source contributor

What is Node.js ?

A brief history of Node.js

  • Created in 2009
  • Used to be sponsored by Joyent
  • 2011: NPM  is introduced
  • DEC 2014: a fork (iojs) is created due to internal conflicts
  • JUN 2015 creation of the Node.js fundation
  • SEP 2015 iojs and Node.js are merged in Node.js 4

Version support

NPM

  • NPM is the package manager for Node.js
  • It is now also used for managing dependencies in most modern JavaScript applications
  • npmjs.com is the most popular module repository in the world

The event loop

Asynchronous programming

'use strict';

// CommonJS import syntax
// 'http' is a standard library
var http = require('http');

// pseudo database
var database = require('fake-database');

var server = http.createServer((request, response) => { 

    // each time a connection is made, this function is called

    // decorate response with header
    response.writeHead(200, {'Content-Type': 'text/plain'}); 

    // add content and end process
    database.getData((err, result) => {

        response.end(result); 
        // The call of `response.end` signals that the callback treatment is done
    });

});

server.listen(3000);

console.log('Server listenning on http://localhost:3000');

Asynchronous programming II

'use strict';

setTimeout(() => {

        console.log('hello');
}, 1000);

console.log('world');

results in

user@host:~$ node helloWorld.js 

world
hello

Is there any success story ?

Paypal

Compared to the same application in Java:

  • Built almost twice as fast with fewer people

  • Written in 33% fewer lines of code and 40% fewer files

  • Double the requests per seconds

  • 35% decrease in the average response time

Node.js reduces development costs !

  • All black Friday mobile traffic is handled by Node.js
  • Servers did not go over 1% CPU
  • Team deployed a new version while 200,000,000 users were online
  • Mobile traffic is handled by Node.js servers
  • Went from 30 servers to 3
  • Application is 20 times faster

Some big Node.js adopter

Making the good choices when starting a project

Use if you want

  • intensive I/O
  • real time features
  • scalability
  • a rich module ecosystem (NPM)
  • to build API
  • to build streaming applications

Don't use if you want

  • intensive CPU tasks
  • to employ developers who are not used to produce elegant and maintainable code
  • to employ developers who are not able to understand asynchronous systems

To node or not to node ?

framework ?

  • Express is still popular but might not be relevant anymore
  • hapijs is a popular high level framework with modern concepts and security features
  • Koa is closer to Node.js native API

So if you want to build with stability, security, and structure in mind, i would personally recommend hapijs. On the other hand, if you want to learn everything, build piece by piece, and code closer to node-core, I’d recommend Koa.

Jonathan Ong, Koa developer

tools ?

  • No need for babel, traceur or TypeScript: Node.js ES6 is enough
  • Need a good test runner and assertion library
  • Code style enforcement has to be done

Production ?

  • Node.js can run as a service
  • There is process managers for Node.js
  • Hide your Node.js server behind a reverse proxy that will handle TLS or other CPU demanding tasks

Conclusion

  • Development costs are reduced
  • Code verbosity is reduced (less  code, less bugs)
  • Hosting fees are reduced
  • Only one language on the server and the client: no need for anyone else but JavaScript developpers
  • Node.js is mature
  • Community is extremely active
  • Some communities such as hapijs' are dedicated to code quality, stability and maintainability. Tools are produced to help achieve those goals

Any 

questions ?

Node.js: how to convince

By Vladimir de Turckheim

Node.js: how to convince

  • 1,041
Loading comments...

More from Vladimir de Turckheim