Menu Home

Node + Express + Jade = Win!

Recently I have been commuting to work via a train rather than by car. Which has been quite good in terms of me having time to work on my Judo related side projects.

As I mentioned in my last post I am working on an exciting project for the Judo community which I have been coding up in Javascript. “Why Javascript?” you ask knowing that I am a Perl developer; well mainly to explore building something larger than I have done before in a new language; with new tools and so forth.

So server side I am using Node and Express, with Jade as the frontend templating engine. I am also experimenting with Javascript unit and end to end (BDD) testing. I am also using bitbucket rather than GitHub; CodeShip rather than Travis. Part of the reason for taking on any side project is to learn.

I have a working prototype up and have now got some feedback from the target audience. First athlete I showed it to wanted photos; so the next day on the train… photos added. 🙂 Second person suggested I should include clubs as well as athletes, so next day on the train added that. Of course, the thord person asked “why have clubs?”; focus on athletes.

So engaging my MVP philosophy, I stopped working on the clubs side and focussed on making the site work from start to finish rather than having half functionality in more features.

Working in a different language has been interesting; Perl is my normal weapon of choice and it’s flexibility and style suits me well. Javascript is not that different in some ways to Perl. It is a flexible scripting language and it has as many quirks as Perl I reckon.

A big issue is switching between one and the other. If I put a “//” for a comment in my office work again I may scream. 😉

Express is not too dissimilar in concept to Dancer2 in the perl world. Some differences; but it’s a router for me mainly with this code. I am no expert in Express; but to date it’s not been too hard or too fragile; it’s coping with my newbie mistakes.

Jade on the other hand has been a bit of a brain twister. I’m used to templating in the basic sense. In Jade (although this is optional, you can do it the other way) rather than merely put variables in your otherwise standard html; you write a template where Jade creates all the tags.

So rather than

<p>This is my #{name}</p>

you put something like

p This is my #{name}

Jade cares about things like indentation; so for a guy used to writing old school templates it has been probably the toughest part to adjust to. Embedding a third party form/button took way longer than it should have… at least till I got sensible and stopped and read the documentation properly and read some tutorials.

On the whole, it has been great working with the new environment. Package.json and NPM makes package management really easy and I know Perl has equivalent way of working. But it might be nice if CPAN (or cpanm) adopted a similarly easy methodology… maybe it does; this could be Mondays train reading. 🙂

 

Categories: Uncategorized

Lance