The Browser Is Dead?
This twitter post by Dave Thomas sparked an interesting back and forth with DHH on how Rails 3.1 could be more opinionated towards web development for the browser. A short time before – it was announced that Rails would include CoffeeScript and Sass as defaults for JavaScript and CSS authoring. FWIW, both of these new defaults are in my opinion the best of the breed fore each task. If you have not done so, I suggest taking a quick read down this thread that I put together with screenshots from my Twitter.app.
The topic is one I have thought often about over the past 6 years. I started writing Rails applications before 1.0 was released and I have seen the changes and felt each one. Having written both web and native iOS apps for HomeMarks.com and retooling the whole application for each major Rails version, I think it gives me a good insight into the pain here. For instance when RJS in Rails first came out, HomeMarks took extreme advantage of it in very clever ways. Pushing rendered partials out and communicating to the browser's JavaScript environment was fun and rewarding at the time. It also felt really DRY at times.
As I started to learn more advanced JavaScript techniques for organizing my rich client code, I ended up rewriting HomeMarks again under the poorly named moniker "The AJAX Head Design Pattern". It even caught a little bit of attention by the Ajaxian and Chris Williams. Essentially what I ended up building was my own minimal backbone.js in that I had a rich MVC layer all written in JavaScript. This usage of Rails as an API foundation on top of a rich JavaScript application was in my opinion a few years ahead of the average curve. Though it was very rewarding from a JavaScript as a language first, DOM second development perspective & it yielded a very clean way to leverage the same RESTful controller actions used by JavaScript in the browser with a native iOS app that integrated with Core Data, it still felt like an over achievement or harder than it had to be.
So as I embark on my third complete rewrite of HomeMarks, I have to think about my tools and techniques again and what the end goal may look like. I have thrown away thousands of lines of OO-JavaScript written in Prototype.js and started rewriting them in CoffeeScript. Though there are still some tough decisions to be made on what my complete stack will look like and how HomeMarks v3 will hopefully again push the new web forward, I cant help but to agree with both Dave and DHH. I also share James A Rosen's opinion summed up in this tweet.
If I had known that RailsConf would be How-to-Use-Rails-as-a-Backend-for-Javascript-Conf, I would've gone!