Node’s goal is to provide an easy way to build performant network programs. This is in contrast to today’s more common concurrency model where OS threads are employed. Node programs are written in JavaScript. By itself, V8 is already a very fast VM, but JavaScript as a language is great – if used right!

Why We Need Non-Blocking
The word ‘asynchronous’ has been around for long enough to become somewhat of a household name. You’re, after all, building high performance servers and apps. Here is a list of reasons why we need to pay attention to non-blocking:

  • Polling is too slow and inefficient.
  • Live interaction requires the server to push data.
  • In order to push data, the connections need to be persistent.
  • The server needs to handle thousands of persistent connections.
  • Threads aren’t going to scale.

What is Express.js?

Express is a simple (lightweight?) framework for Node.js application developers. The Express.js framework is built on top of Connect – an extensible HTTP server framework for node using “plugins” known as middleware. MVC architecture on the server side.

Express 4 no longer depends on Connect, and removes all the built-in middleware from its core, except express.static. This means Express is now an independent routing and middleware web framework, and Express versioning and releases are not affected by middleware updates.

In retrospect, Connect is for making frameworks. Express is a lot more easy than raw Node.js, but still retains the low-level class.

Here is a quick example of an app built with Express:

// Express.js Demo App Example
var MyApp = express.createServer();
// creating our Express app
MyApp.get('/', function(req, res){
// We just setup a route handler!
// Launch the HTTP server

that wasn’t so hard, was it? Luckily, it’s not just a simple Hello World that’s so easy to build.

Node.js is a low-level I/O mechanism which has an HTTP module. Unfortunately, by using just the HTTP module – things like parsing the payload and cookies (or storing sessions) will need to be re-implemented. This is where Express comes in really handy (no need to repeat the same code over and over again), by providing you with the necessary functionality to use with the HTTP module.

How to install Express.js?

In order to install Express, you need to have Node.js up and running. The next thing you need to have is ‘npm‘ (Node Package Manager), and as soon as you install that – grab the Express-Generator package. You’ll need that for generating Express applications.

$ npm install -g express express-generator
$ express CodeCondo
$ cd CodeCondo && npm install
$ node app.js
>> Express server listening on port 3000

You should have a fully functional Express application, listening on your localhost’s port 3000. At this point, we’ve looked at the general description of Express.js, and also some of the terms that clarify connections between Node.js, Connect and Express.

Node.js Frameworks & Books

I first wrote about Express back in February, it was in my post about minimal frameworks for Node.js developers. In there, I only touched the surface of what Express is, and what kind of sites are using it to power their infrastructure. Today, we looked at ways of installing Express, how to launch an app, and also a bit of background check for future reference.

By the way, if you enjoyed the list of minimal frameworks, take a look at my second post for Node.js application frameworks that are slightly larger in size (though, you’ll find more people using Express anyway) – that post was also particularly successful, and combined – there have been hundreds of thousands of visits to both of these posts. Node.js is surely in demand!

But, if all this is totally new to you and you feel like you could begin learning a new language (such as Node), then here is a post that talks about some free to download eBooks for learning and mastering Node. Unfortunately, it is not up to me to update these books, so recommendations for more of the same type books would be awesome!

Node.js Growth

The inspiration behind this particular post was actually something that I wrote yesterday. I published a post that talked about The State of Node.js, and I felt that I need to dig a little deeper, and perhaps give everyone easy access to such short guides as this one. Would you like to see more? It all comes down to what the community wants.

How to Get Started with Express.js

I’m looking forward to more stories, tutorials and guides on how to use Node.js to its fullest potential. I’m also keen on hearing your feedback on topics you’d like to see being covered, unfortunately – it’s only me (for now) managing this project, and trying to please everyone at the same time is simply not viable.