2010 – A good year for the Dark Arts
Posted by Dave Bouwman | Posted in ASP.NET MVC, Personal, Rails | Posted on 13-01-2010
8
Ruby on Rails may not be on a Lovecraftian list of “Dark Arts”, but for someone who’s been developing on the Microsoft platform for the last 10 years, it’s close enough.
As anyone who’s read this blog in the last 2 years knows, I’m a pretty big fan of Microsoft ASP.NET MVC – it’s simple, gets out of your way, and gives you total control of the output. And it’s 1000% better than the mystery meat known as Web Forms – a nirvana so to speak. So, why would I take up Ruby on Rails?
Why Rails?
First, unless you’ve been under a rock for the last 5 years, you’ve likely heard that Ruby on Rails is *teh awesome*, so that counts for something. Then there is the fact that Andrew Turner (@ajturner for the Twitterati) / GeoCommons crew as well as Paul Bissett / James Fee and the WeoGeo team are all smart as hell, they all love Rails.
And the other reason is that realistically, Apache and Linux have won the web. Yeah there is a large slice of the pie (mainly Government) that runs Windows, but if you are starting a web based business, you’re likely going to run open source because of the costs to start and scale. Sure Microsoft is semi-mitigating this with BizSpark and a few other programs, but regardless, the difference was put in sharp contrast as I tried to negotiate may way around the Microsoft Open Licensing site while at the same time installing RedMine on Ubuntu Linux. For those who have not had the pain pleasure of dealing with the maze of Microsoft Licensing sites, they are among the least usable, obtuse sites anyone could imagine. It’s like they set out to win an award for painful web experiences. Really – I don’t mind paying for software – I love Visual Studio, but why, why, why must it be a living hell to actually login, locate, assign and activate licenses? I’m not joking here – I’m really considering changing from full MSDN subscriptions over to just buying Visual Studio because then we own it outright and don’t have to deal with this crap licensing site every year.
Anyhow… back to my point. On Ubuntu installing software is crazy simple – “sudo apt-get install <software of choice>”. Yes, the command line syntax is slightly more complex than a “Ok-Next-Next-Next” windows installer, but it’s also free, immediate and you’re always getting the latest and greatest.
When the main reason we use MSDN over just Visual Studio is for the SQL Server and OS licenses, it makes me question things – I can install MySQL in about 5 minutes, it’s 100% free and I don’t have to fight with the Microsoft sites? The OS is free, and Aptana RadRails (free) covers the IDE side of things? Why is it that I’m shelling out $15,000 a year in licensing, only to have the entire Microsoft interaction be painful? Ok this is degrading into a rant, but what the heck, I don’t rant very often, and it’s my blog anyhow… moving on
Ruby on Rails. Yeah. So, it seemed that expanding my horizons a little may be interesting, and worth some evening time. I started with “Rails for .NET Developers” from Pragmatic Press. This is a perfect read if you’re a WebForms developer, and pretty good if you’ve elevated your game to MVC. From there I moved onto “Agile Web Development with Rails” and this is a great follow up. If you like Pragmatic Press books, these are perfect.
Patterns nom nom nom…
Since Rails is based on the MVC pattern, and a major influence behind ASP.NET MVC, it’s not surprising that the carry over from ASP.NET MVC is huge. The View syntax is very very similar, the the extent that many of the HTML helpers are very similar. This is great because I was immediately comfortable with the general structure of things. However there are some differences… namely data access (aka ActiveRecord)
Because this post is rife with asides, let’s have another… It’s interesting that Rob Conery, of Hawaii and various levels of internet fame (creator of SubSonic, an ex-Microsoftie and now TekPub.com dude) seems to have been going through a similar thought process / experience as I have, although he seems to be a few weeks ahead of me. You see, while I really like ASP.NET MVC, there is still WAY too much time spent thinking about data access. In the last year, we’ve used the Repository pattern, with a mix of SubSonic, NHibernate and plain ADO.NET. On every project there is much hand wringing and thought about how the data access tier should work – how “POCO” should the POCO’s be, what handles the transition from the data tier to the models etc etc etc. In this post about Entity Framework and NHibernate Rob makes the point that we should be waaaaay past thinking about the data tier. It should be “done” – the fact that there are still flame wars about data persistence options is sad. Isn’t a framework supposed to *help* you with the mundane stuff?
I can haz Data Nao?
I my mind, time spent futzing with the data tier is time wasted. Yes, there are projects where you don’t control the database, and some DBA’s do some really wack stuff (if we meet, ask me about this, have I got stories!), but in an ideal world you turn down those projects. Any database that makes it a royal pain to get to the data the users need, is poorly designed in my opinion. The app is about users, and it succeeds or fails based on them, not based on some idealized 4th normal form, so let the app dictate the data model!
What rocks about Rails is that data access is “just done”. No thinking, it’s just done. And it works. Let me say that again – the data access is “just done”. You can go from zero to editing data in your database in about 30 seconds. Sure the styling of the scaffold sucks, and it’s not the best workflow, but the key feature – create / edit / update / delete data in your database is DONE. All that time you would have spend thinking about NHibernate caching or optimization can be spend working out a better workflow or UI styling. Under the covers, I’m sure there are more elegant solutions, and there are likely some performance issues, but realistically 99.99% of web apps are not FaceBook or Twitter, so the performance / scalability arguments are moot – we’ve got trivial numbers of users and heinously powerful servers. Let’s NOT sweat performance mmmkay?
The other thing about Rails that’s great is that it’s opinonated. And not just mildly, it’s got some really strong opinions, but if you can work with them, and not against them things flow so smoothly. I know, I know, I heard this same speil for a few years, but I have to say it’s true. If you can live in the 80% case, Rails makes things so smooth it puts a grin on my face.
What Now Brown Cow?
So, am I forsaking all that Redmond hath wrought? Not quite – this is good kool aid, but I’m not about to throw out ASP.NET MVC just yet (we did just shell out for another year of MSDN after all!) but Rails provides an exciting alternative that’s close enough to the tooling and workflow of my day job that it’s providing inspiration and ideas about how to be a better ASP.NET MVC developer. It’s a great developer exercise to learn a new language or framework, and I heartily recommend checking out Ruby and Rails.
Anyhow, to close out this rant of a post, I’ll be throwing more Ruby into the mix here and on GeoGeek.tv. At this point I’m certainly still very NOOB in terms of Rails, but what I’ve done, I’ve liked. Alot. And as far as “on my own time” projects, I’m sensing a definite shift to the dark side. Welcome to 2010!

