Ruby on Rails from a C# Perspective
Tuesday, April 17, 2007 at or around 01:26 PM
Well… So, it looks like I bought into the hype. I’ve now completed rewriting this weblog from C#/ASPNET to Ruby on Rails.
It’s kinda funny, I guess, that I spend time writing, (and rewriting, and rewriting, and rewriting) this weblog when I never actually write in the damn thing. So it goes.
I reckon it’s become an interesting project for me these days, and a good practical exercise when working with a new language or a new environment. And, since I’ve written the damn thing at least half a dozen times now, I’ve learned a lot about what it means to build an effective administration UI, what it means to keep the data in the DB portable (because I assure you that in a couple of months I’ll be looking at rewriting this in smalltalk, python, or lisp), and how helpful it is to fully separate your logic from your presentation.
Anyway… back to the subject at hand: some of my perspective as a C#/ASPNET developer on Ruby on Rails, and how porting this blog to ROR went. There’s a number of things about ROR that I really like, so let’s let the glass be half-full, and start there.
- Ruby is an incredibly “clever” language. There’s a lot of little stuff that (once you get the hang of) you think: “Well doggone, that’s pretty clever…” Before starting with rails, I actually tried to dig into the Ruby language itself. This document I found to be both well written, and pretty useful.
- After about a week, I found Ruby syntax becomes incredibly automatic (albeit still very weird). There have been a number of times where I’d think to myself, “That can’t be the right syntax…” but, I’d save the document, try it, and sure enough, it would be right.
- The Rails framework is also quite clever. It does a great job of cramming MVC down your throat and making you really keep your code tidy.
- Obviously, the extremely demo-able scaffolding is very smart, but there’s a lot of other really smart stuff, like generating XML documents programmatically with rxml. I’m sure many of the features of the framework could be built in C#, but it’s very nice to get them for free.
- I’ve found myself really liking the way the ActiveController “method-as-page” metaphor works. It organizes your code in a very different way than a traditional ASPNET web application, and is pretty cool.
- The built-in webserver for development (mongral on my macbook) is awesome. The VS 2005 built-in development still server has quite a few bugs, and the goddamned thing still does not want you to run your web application at “/”.
- And not to be a broken record, but the rake tool—especially when using it for database migrations is really clever. I’m looking forward to diving in a little deeper here, because it feels like I’ve only scratched the surface.
- Another small thing: the Rails’ built in logging, is also nice. I’m tired of always having to BYO logging to my ASPNET web applications.
Now, after all that praise, let’s talk about what doesn’t work well from my perspective…
- Probably the biggest issue I have is that I miss my IDE. VisualStudio, even with all it’s lumps and warts, I still think is a fine IDE. For Rails development, I’ve been using TextMate and, while it’s a fine editor, I really miss all the goodies of IntelliSense™, tab-completion, class browsing, and inline debugging.
- Speaking of debugging… From what I’ve read, it’s fairly lame in rails. I say read, because with my macbook I currently get “Breakpoints are not currently working with Ruby 1.8.5”. Right… That makes it just about useless.
- The ruby language (which I just praised above) I have to admit, I’m really not a fan of.
- You can use parenthesis, but you don’t have to.
- You can use curly brackets, but you don’t have to.
- You can use line breaks, but you don’t have to.
- And whitespace formatting is all over the map.
So, when looking at code examples, you end up with all kinds of variations of people’s writing style, including some very perl-esque long single lines of code that are doing 8 or 9 different things.
Powerful? Sure. But damned confusing when you’re trying to read it. C# might not be the best language in the world, but it really does lend itself to reading well. Having VS also enforce basic formatting rules, helps keep things consistent, too. - Documentation, documentation, documentation. Both the Ruby documentation and the ROR docs are pretty pitiful. Say what you want about .NET, but the MSDN documentation is pretty damned good. One of the things that drives me crazy in the Rails API is for many methods there's just an “options={}” as one of the args, but no mention what so ever as to what these mythical options may be.
- Although I think I need to give it another shot, I wasn’t very impressed with RDoc. Again, VS and it’s Xml Comments setup seems much more practical, easy to generate, and infinitely more readable.
- Did I mention how much I miss IntelliSense™? I really, really do.
All in all, it's been an interesting experiment. I’m not sure I’d ever choose ROR for a “real” development project (I still have lots of questions about fcgi, and some of the more “backendy” things that rails does) but for building internal tools, or (like this case) a simple blog, it seems pretty slick.
I imagine I’ll tinker on modifying this weblog app a bit more, and then try and rebuild one other side projects in rails—an online photo album