23.6.15

90 days of node.js - Day 9 expressworks

In case you don't know what this is all about, the out-of-loop link describing my 90 day journey through node land.

I was talking to a colleague yesterday and we were yakking about node. He has been experimenting with node.js for a while now and has been trying to sneak it into our regular workflow. Battle of attrition imo, but what can you do :)

One thing we both agreed on immediately was something I have been observing in the node community in general. I think I can safely bundle the users in 2 categories:

  1. Node core developers - mostly backend folks. Comfortable in cli.
  2. Web application developers - Very comfortable with web apps on browsers, maybe not so much on backend.
Based on the documentation alone, I can see that the core node docs are very much geared towards people building server side cli tools. The extensive module development seems to be a catch-up game that regular web devs are playing so that their chosen backend framework can work just as easily as their regular favorite backend framework. This might be a generalization, but that is the only thing that explains to me the fantastic array of modules - each of which is solving a problem already addressed in other languages. It's a fascinating time to be writing ndoe code though.


Which brings me to Day 9. This was another mixed day - primarily because of lack of time. I was able to get thru expressworks - another workshopper that deals with express.js. express touts itself as a "fast, unopinionated, minimalist web framework". From the looks of it, express to me looks very much like spring-mvc. The code is fairly light to write - a little bit of boiler plate and then it just works. There is just so much functionality it exposes that my eyes basically glazed over the documentation. That said, express folks have done a stellar job organizing the documentation. The API reference is as good as the best put there and was easy to read and use immediately. I intend to use express as much as I can for the the foreseeable future as my UI layer just for that reason - less ramp up is always better.

My first impressions based on the workshopper are fairly positive. It is pretty easy to setup a basic express server and start routing both static files and responses generated from template files. express is pretty flexible about what template it supports and how to wire in that support. The most intriguing thing about express though was the concept of middleware. Middleware is the ability to plugin different actions on an incoming request before computing and returning a response. It's essentially like filters in the java world. The examples I have seen so far didn't demonstrate ay interesting deviation from the filter principle. express gets this from connect (which it doesn't use in v4.x and above) an interesting node module from sencha. Routing and param binding is the other big feature of express. I didn't find a dispatcher yet, but I can only assume something like that exists already.

The workshopper was again really good, but not great. It introduces express in somewhat big leaps. The exercises themselves were fairly easy to work out, but the instructions could use some work. Unlike the previous workshopper,s hints were exactly what they said - the entire solution was not provided and I had a more productive time going over the express documentation. Much fun, definitely recommended.

My workshopper solutions are on github. Two minor things that I didn't know, but now that I do I feel good about knowing. Using npm init to initialize a package.json AFTER you have run your npm install commands is really useful. It brings in all the node dependencies in the correct order. Especially useful when working with workshoppers that throw random modules at you. Similarity, git init helps to simplify the git checkin process once the modules are done ( don't forget to update your .gitignore file and have git ignore all the dependency cruft).

Overall a good day. Tomorrow I plan to refactor my twitter-list api and also move it to a UI home.