Recently I have been toying around with AngularJS with in a Ruby on Rails application. This had really been my first major use of anything other than jQuery, I am a huge jQuery fan and have been way before I got into rails. After taking a really great tutorial from Anthony Alicea on Udemy.com it was instantly clear to me. AngularJS is badass, and I should be using this more often! Two way data binding seems like something that should be available in jQuery but I have not had too much luck finding anything good, until Angular.
To get my feet wet and start learning some of the in’s and out’s of Node.js I went back to Udemy.com for some help. This time I was not so lucky in finding a “high” quality tutorial. It looks like everyone who had a crappy mic was making tutorials on Node. This led me to a mix of places, and finally landed on a tutorial talking about a “framework” like thing for Node.js called ExpressJS. It quickly reminded me of Sinatra on Ruby, and I was immediately comfortable. My next hurdle was finding out what this “Jade” stuff was all about.
Ok first off, why? Secondly, what? As a Rails developer I have known about haml and some other templating languages but, when did HTML become so hard to write or use? Why do we feel we need to replace this easy to use and understand language? I asked that very question to some developer friends: “Why replace HTML with Jade or any other templating language?”. Most developers who could offer up an explanation said they can write it faster than HTML alone. Others stated, “HTML is too dirty” as in it was hard to read or debug.
I gave Jade a very good look over, and then played with it for a week or two on some test applications I was building. I personally am not a fan, HTML is easy and I don’t see any reason to replace it with something that has to be parsed and converted to HTML.
Back to NodeJS & ExpressJS… also AngularJS
With the decision not to use Jade, I was looking for alternatives when I discovered that I could simply use HTML and AngularJS as my front end. So I started a project with Node.js and ExpressJS. Creating an API, I got into my second or third endpoint when I realized what was going on and said “Why am I doing this in NodeJS?”. Why was I creating an API in Node and not something like Sinatra or Rails with endless helpers and gems to get the job done? I quickly said to myself that I am just learning this, and there has to be an “ah HA” moment! I will not keep you waiting, that moment never came, but why? After I had built a project and finished it, I was very proud of my accomplishment and started to really think about why I would use Node.js+Express over Rails for any future projects.
I did like that Node is self contained and had a package manager, then was also simple to install and run on a server (very similar to bundler for Ruby). I also liked the speed and concurrent connections you can get from it.
Many state that Rails is too black box or magic. I often reply, “What’s so wrong with that?”. I often get the typical, “Once you step out of CRUD or want to do anything complicated Rails forces you to do it the ‘Rails Way’”, of which I also reply “What’s so wrong with that?”. Rails forces a standard that any other Rails developer can walk in and go, “Yep, I know what’s going on here”. As a developer that started with PHP, I know that not having any standards is a royal pain in the ass for the next person that has to look at my code. Thus becoming the black box anyway. Rails takes care of your low hanging fruit and allows you to get to the meat, quickly. While Node has some ORM options, why not just is a real ORM in Rails and be done?
Conclusion, I think…