Why I’m excited about JavaScript and Node.js

4 months ago — Comments

I’m really excited about the web. For the first time, I am seeing it as a medium to deliver applications that rival native user experience and take advantage of the web’s distributed nature. With browsers becoming increasingly capable, applications can now be built entirely with JavaScript and run completely in the browser. By moving apps onto the client and away from the request and response paradigm, servers that were once responsible for rendering obtuse HTML views or tracking state in a multi-page form submission can be stripped down into minimal API servers that ship JSON data to and from the clients (perhaps even in real time).

In addition to a more responsive interface, this dichotomy between server and client offers a lot of advantages. It means your backend is small and focused- defining a single entry point to your application’s data. The web client will interact with this interface but so can mobile and other third-party apps. Since the application and the application’s data are now completely separate entities they can now be distributed across the web as desired. The Unhosted project is doing some awesome work in this regard.

Why Node.js?

For those unfamiliar, Node.js is a small layer around the JavaScript V8 engine (the thing inside Google Chrome) that additionally provides access to the network and filesystem.

In my opinion, data-centric server backends like the ones described above are the sort of thing at which Node.js excels. It’s not uncommon for an application backend to be interacting with data in various places (i.e. databases, third-party APIs, filesystem, client connections, etc.) and this is Node’s strong point. Rather than interact with each resource one after the other (as is typical in most environments), Node.js can perform all these actions simultaneously and return the results asynchronously. This means both faster requests and the ability to handle more concurrent requests.

Perhaps more importantly, using Node means that JavaScript is everywhere. Your client-side application is written entirely in JavaScript, it’s sending JSON (JavaScript objects) back and forth to the server which can now also speak JavaScript. Throw MongoDB or CouchDB in the picture and your entire application stack can be written in JavaScript. This is a big win when you can start reusing code in multiple layers of your application.

So…

Moving your application to the client and/or writing your backend with Node.js is obviously not the right fit for every project, but if you’re a web developer then you’ve inevitably dealt with JavaScript. It’s unavoidable. Embrace it where you can and prosper. It’s a simple language at its core but provides a tremendous amount of flexibility and potential. If nothing else, take some time, put jQuery aside, and learn the ins and outs of JavaScript the language.

Here’s some resources that I’ve found valuable in my quest to re-discover JavaScript: