Escape from Callback Hell

You probably heard about asynchronous code and that it is hard to work with. In this article I'll share simple approach that makes working with asynchronous code easier.

Let's take a look at sample case - we need to authenticate user on the remote service, get list of his comments and render it in HTML.

There are three asynchronous functions - authenticateUser, getComments(userId) and renderComments(user, comments).

var authenticateUser = function(login, password, cb){setTimeout(function(){
  var user = {id: '1', name: 'admin'}
  cb(null, user)
var getComments = function(userId, cb){setTimeout(function(){
  var comments = [{text: 'some comment...'}]
  cb(null, comments)
var renderComments = function(user, comments, cb){
    var html = + ' wrote ' + comments[0].text
    cb(null, html)

Now let's write code that uses these functions and handles errors properly.


Ruby on Rails vs Node.js

I wanted to see benchmark that more or less close to real life, not just measuring how fast it can stream data via http.

So I created application that query some text from remote HTTP service (service delays each request for 200ms) and render HTML page using that text.

It simulates how Web Framework performs when it needs to wait for response from DB or other services, how fast its templating engine is and also how fast it is itself.

And hit it with wrk -t2 -c100 -d10s http://localhost:3000 you can see results on the picture.

Benchmark Ruby on Rails vs. Node.js

3782 vs. 2914 hits, average response time is also very close.


Create simple shop.

In this course we create Cart Widget that can be embedded into sites in order to allow its users to buy products and send orders to the site owner.

You'll learn how to:

  • Quickly prototype User Interface with Twitter Bootstrap.
  • Build REST API using NodeJS.
  • Use REST API in Browser with JavaScript.
  • Keep markup and code clean using Client Side Templates.
  • Simplify CSS styling using Browser live refresh.
  • Create dynamic Forms with JavaScript and validate it.
  • Instant reaction UI without blocking, waiting and progress.

Drawing UI

Shop and Cart