In my quest to learn new things, specifically the following things, I’ve been both excited and drained:

By “new things” I really mean “some cutting edge stuff that seems pretty cool”, the “cutting edge” portion being the source of most of my struggle. New tools, languages and software have sharp edges.

Since I love fast and light software, node.js is my current casual focus. Also helps that I’ve been learning more JavaScript lately (through work and various side projects).

I’d heard of Sinatra for Ruby and figured I’d like to try a similar micro-framework for node. Stumbled across Picard on github a few months ago, but forgot about it … Last week I noticed Express on the node github page, installed it, and proceeded to hit brick walls.

What, I have to install npm, a package manager? Makes sense, but had a somewhat awkward installation process. Can’t stand dependencies that I’m required to install manually (it’s not in apt). It’s just not ethical.

I eventually got npm installed, then installed Express using it. Fine. When I go to dive into Express, I see it likes to use jade for templating. Think I tried using haml and that failed. Sounds nice, but jade won’t install via npm. And “npm update” doesn’t work. When I try to re-install npm, it doesn’t change a thing. So npm seems hosed … might as well avoid having to use it at all. I can handle that!

Luckily I stumbled back upon Picard. So I downloaded the source, copied the sample app code into own, pointed my app at the picard libs. Done! Heeeeaaaawwww! And picard uses haml, out of the box, nothing extra to install. Yes! Fists shall forever be raised at dependencies (ok, not really).

So now how about database access? Came across a few ORMs listed on the node wiki page, because I really don’t want to start from scratch with sqlite3 on node. Nor did I want to interact with Redis directly from node.

biggie-orm seemed promising. Had a nice API, but I couldn’t get it to save. Looking back on it, maybe it was trying to use MULTI and the version of redis for ubuntu doesn’t support that command. Damn.

Found a few other redis orms … redis2json which is read-only. It reads into a json data structure. Nice, but I need to save too, and I don’t want to do it by hand. redis-node-client kept bombing on me, outputting dirty characters. redis-node works, but when I tried to use transactions (which seems to be the right thing to do), I ran across the fact that MULTI isn’t supported. Shit.

Later that day I found mention of node_redis, specifically that it’s FAST, and has transaction support. So I manually installed a newer version of redis in my home directory, tried biggie-orm again and it still wouldn’t save all the data. But that’s where I stopped.

What can you learn from all this?

That redis looks fun, and even seems to model some patterns better than databases do. Specifically looking forward to using this to get back ids of objects that have all the specified tags:

sinter tag:1:objects tag:2:objects tag:10:objects tag:27:objects

sinter stands for “set intersect”. Each additional parameter is a key in redis whose value is a set. So it fetches the values for those keys and intersects them. The elements in the “tag:1:objects” set are ids of objects that have tag 1.

Node also looks fun, requiring a new way of thinking about code, especially code that involves any sort of IO. You have to write it in Continuation-passing style.

Whew. Too many links.