Skip to content

Instantly share code, notes, and snippets.

@rrgayhart
Last active October 17, 2016 16:16
Show Gist options
  • Save rrgayhart/2bae15df288835c4919e694a000eeb45 to your computer and use it in GitHub Desktop.
Save rrgayhart/2bae15df288835c4919e694a000eeb45 to your computer and use it in GitHub Desktop.
GameTime: Webpack v Node

Webpack

Use Cases Where Webpack May Not Be Enough

  • Multiple pages, endpoints
  • A relational database
  • Websockets
  • Hosting complex client side apps

Node

Node is a platform for JavaScript applications. Blending the virtual machine that Google Chrome uses (V8) for server-side programming.

The official definition of Node.js is 'a platform built on Chrome's JavaScript runtime for easily building fast, scalable network applications. Node.js uses and event-driven, non-blocking I/O model that makes it lightweight and efficient for data-intensive real-time applications that run across distributed devices'

More Info and Opinions

  • Node tries to keep consistency between the browser and the server by reimplementing common host objects, such as:
    • Timer API (i.e. setTimeout)
    • Console API (i.e. console.log)

Benefits to Node over, say, Rails

  • Same language on server and client - less cognitive switch
  • Server, since based on Chrome, has the newest and most up to date versions of the language

Async

Ajax in the browser:

$.post('/resource.json', function (data){
  console.log(data);
});

The filesystem in node:

var fs = require('fs');
fs.readFile('./resource.json', function (er, data){
  console.log(data);
})

Both calls require an async response

Resources

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment