Last week Rudy and I at Yetihq.com attended the Node.js developer meetup, which was hosted at Engine Yard. We listened to Matt Pardee describe a web application stack on Node.js. I’m going to summarize take away points from his talk and then provide my own opinions.
Node.js is a lightweight platform for building a server application, which offers an event-driven framework for handling socket input and output. This is really useful for customizing Node.js to solve a specific problem, and it makes Node.js very fast. In most cases, though, we are building applications that are similar to one another, such as a web application. Rather than reinventing the wheel each time, we take advantage of open-source frameworks that help build a web application on Node.js.
When building a web application framework, a web browser makes HTTP requests to a web server and the web responses back with content. The Express.js framework encapsulates this behaviour in Node.js so a developer doesn’t have to handle sockets directly. For serving HTML content to a web browser, the Jade template library provides an abstraction from writing HTML. Over time many reusable components in a web application are needed, such as a database connection or authentication library. The Architect framework provides a convenient structure for including such libraries into a Node.js application.
Those familiar with building a Ruby on Rails or Python Django web application will immediately notice that we already have web frameworks and reusable open-source libraries. The programming language in which they were written, however, are silos that prevent library reuse. So we reinvent the wheel for each programming language.
The trend in Node.js is a reinvention of the pieces that eventually result in a heavyweight framework. Heavyweight frameworks provide all the features you need out of the box at the expense of additional computation overhead. The computation overhead, however, is an acceptable tradeoff because a developer’s time is more valuable spent in writing custom business logic. The ecosystem of libraries in Ruby on Rails and Python Django offer many reusable libraries, which reduces development time. I believe the same trend is happening in the Node.js community and that a heavyweight framework will emerge.