David Heinemeier Hansson, I want your babies
Posted by johnnie
Have I mentioned how much I love Ruby On Rails recently?It’s just … so … I’m sorry, I’m too emotional right now. I have a fairly standard process of development when I’m learning a new language or tool (or both, in this case). It’s an iterative process, which involves me learning the basics and thinking that I understand it, then going back to the beginning and learning it all again, and really understanding it this time. I finished iteration 2 for Ruby some time ago, and I’m now well into iteration 3 (actually using the damn thing in a sufficiently productive way that I actually achieve something other than working through tutorials). For the Rails framework, though, I haven’t got quite as far. I’m right in the middle of iteration 2 now, and I have to say I’m loving it. Iteration 1 was enough to make me phone up all my friends to tell them how great it was, but now I really love it.
I’ve been trying to decide why, and I’ve broken it down to the following:- I’ve never really had the occasion or the need to work under a strict Model|View|Controller structure before, so I’ve never really investigated it. The whole thing looked like too much hard work, to be honest. Working under MVC with Rails, I’ve begun to realise that this is how I tend to write code anyway (at least, on my good days). I find it almost totally intuitive, and it makes me structure my code well. It also makes me think about how I’m going to do things before I rush off and do them, which is a good thing, and leads to much more scaleable code.
- Ruby is just beautiful. If it’s possible to feel a platonic yet vaguely sensual arousal for a programming language, then I’m there. Even better, Ruby lends itself very well to templating. You can express almost anything within Ruby simply and elegantly. In a lot of cases, the code you write could be picked up by a non-programmer and instinctively understood.
3.times.do total_price = total_price + item_price end - The whole Rails framework has obviously been written with a great deal of forethought. It’s not just that it has easy and structured helpers for common tasks – Rails seems almost able to predict what you want to do next and do half the work for you.
- Whilst we’re on the subject of helpers, some of them are so damned clever that they make me sit up on my chair, clap my hands with glee and giggle like a schoolgirl, before muttering “Ooh … that’s clever …” and returning to the code.
- With Rails, you don’t need to do the boring stuff. There are scaffolds and code generators to automatically churn out the skeleton of your application so that you can get stuck in to the fun parts straight away. Rails uses the Ruby ActiveRecord library as an abstraction layer on top of your database. This means that 90% of the time you can forget you’re even working with a database, and just treat all your data as classes and objects. You can’t really understand how cool this is until you try it. You’ll never have to write a mysql_connect request again. Think of Rails as the Work Experience kid that you give all the shitty jobs to. Now imagine that the WE Kid is much faster and more thorough than you could ever be. The WE kid never complains. You can download extra bits and pieces to make the WE Kid better or faster, or make the WE Kid do new stuff. After a little while, you may want to marry the WE Kid.
- Rails URLs are pretty, or at least prettier than most. No ugly appended query strings. No UIDs or hashes being passed by URL (which is a bloody stupid way of doing things anyway). Your PHP URL that looked like this: http://www.mystore.com/add_product.php?product=1234&session=AAFJ43545FFSssjkjfdfdkAAA&discount=true becomes this in Rails: http://www.mystore.com/store/add/1234 That’s just out of the box (and pretty badly coded, actually). You can make it much prettier if you want to spend the time.
- Rails has a thing called the Flash, which is bloody clever. It’s just a way of passing messages (any data, actually) from one page to the next. If you make a call to display the flash at the top of your page, though, then you can pop up status messages and warnings dynamically, and in total context. They won’t be there if the user reloads the page. Unless you want them to. Rails has an easy way to override the defaults and store them permanently, of course.
- There’s a free IDE for Rails called Radrails. It’s based on the Eclipse IDE, but has been heavily restructered to make it ideally suited for Rails development. Using Radrails, it feels like the authors have taken one look at the speed and beauty of Raisl development and said, “That looks like far too much work. Why don’t we write a tool that will make this already ridiculously easy framework even easier?”
- Rails is agile. Remember those times in PHP development when you realised, way down the line, that you needed another three rows in that database table, and so you needed to restructure all of your code to take advantage of them, and then regenerate everything and blah, blah, blah? Here’s how to do it in Rails : add the new rows. That’s it. ActiveRecord automatically adds it to the model, and you can call on the new variables right away. Your old code hasn’t broken, you’ve just got extra functionality.
- Why The Lucky Stiff’s Poignant Guide To Ruby. No words can explain this.
I’m also not sure yet how secure my code is. I know the common things to avoid in Rails, and I don’t think I write particularly insecure code, but I’m not as confident in that assertion as I would be in, say, PHP. The recent Big Frigging Security Hole in Rails hasn’t done much to allieviate my fears.
I still love it, though. Now all I have to do is find a job where people will pay me to use Rails. How cool would that be?

Rails rocks all our worlds, and was rather happily useful when a coursework I was assigned turned out to boil down to setting up a scaffold and then submitting :)
LOL – now, that’s just downright cheatin’.