Tuesday, November 13, 2012

My Foray: Developing Ruby on Rails, CoffeeScript, Mongo, ElasticSearch on a Mac

The one thing I really like about where I'm at now is the diversity of projects I've been able to work on in the last 8 months. My current project is a welcome divergence that has rekindled my admiration for the command line.

In the past 2 weeks I've had to come up to speed with not only developing on a Mac (a very nice 13" MacBook Pro w/ Retina display), but also developing the backend API using Ruby on Rails (v3), the client side using CoffeeScript and ElasticSearch for the indexing (Mongo is becoming less of a requirement for us).

Luckily package managers like HomeBrew and RVM have made environment setup easy [enough], Git is ... well Git, and WebStorm + Sublime Text 2 are the IDEs of the day. It all works just fine, but I can't get over the feeling there is just too much "magic" and hand holding, specifically in CoffeeScript, but also in RoR.

... more to come later ...

Friday, August 10, 2012

Ooohhh, so that's RESTful ...

Slacker == this guy
Looks like I'm as guilty as many of my fellow developers about being lazy and not truly understanding what constitutes a true RESTful service. In this blog post, it's summed up quite nicely. The big "ah-ha" moment for me (much like the author of the blog post) was about hypermedia and how the return data was used as self-describing / revealing for getting more from the API.

I'm internalizing this and what it means for my future projects. Probably not a good idea to continue to puke back a JSON / XML representation of a server model at the end of a GET endpoint and call it a RESTful service, even if the client can DELETE...

Thursday, August 9, 2012

Node.js Foray

In the beginning ...
I've made my career based on Microsoft web based technologies (VB6  + ASP 3 ... ok you're right, not the best way to intro ;), Windows Forms, ASP.NET Web Forms, SharePoint, BizTalk ... yeah, again, I know), and I've always leveraged JavaScript to fill the void on the UI side of the equation. I started with the now classic:
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
combined with hand rolled XML schema's to lighten context changes (async save operations for instance), but I always felt it was a bit of a hack and/or brittle.

Then there was light ...
I made the switch to ASP.NET once they introduced MasterPages in 2.0 (I tried ASP.NET 1.1, but wasn't sold on it at the time), and it was clear that the future was before me, but, the JavaScript story was even worse in some regards than it was in the classic ASP story (Web Pages 2.0 anyone?). Microsoft realized this and introduced what was, at the time, a pretty good stop gap called the AjaxControlToolkit, which is still ongoing, but it still was a bit more cumbersome than it should have been and didn't pass the "sniff test" in my mind.

and on the seventh day ...
Fast forward to where I am today where I am architecting (apparently not a verb), developing, deploying and supporting a full JavaScript Model-View-* client-side application and subsequent script widget (based on Knockout for the admin, Underscore for the widget) and I can honestly say, this is the most fun I've had developing web applications in a long, long time.

... and it came to pass
The more I've been working with these libraries / frameworks on the client-side (see Steve Sanderson 's terrific post about this apparent debate), the more I've realized I've been missing out on the Node.js + MongoDB server-side experience. It was time to fix this as I've always personally dabbled in alternate technologies (PHP, JAVA, Perl) that never translated to my professional career, but were none-the-less interesting.

Node.js + MongoDB on Windows
The first thing I wanted to know was if Node and Mongo was even supported on Windows, or if I'd need to run a VM of Linux. The good news is that, yes, they are both supported, and in fact, Microsoft of all companies, has the Node part wrapped up nicely. Using Microsoft Web Platform Installer (WebPI) + WebMatrix took out much of the guess work on getting a Node instance stood up, and even includes the popular Express MVC framework. Being one to want to look behind the curtain, I instead used the Git repositories instead, and ran them from the command line, but it didn't buy me much.

On a side note, I did end up spooling up an Ubuntu instance ... more on that in another post (it still isn't something I'd suggest to a non-technical person).

After installing WebMatrix and IIS for Node.js using WebPI, I was ready to start creating.
I chose the empty template and used npm to install Express and the Mongo driver without issue. I'm very early on in my investigation, but I have to say, the ease to stand-up a JSONP and Socket.IO server is so simple, it's making me wonder where the pitfalls are ... I'm really digging JS on the server and JS MV* on the client for the next generation of applications.