05 Dec, 2008

Published at 07:24PM

Tagged with ruby, rails, programming, and reflection

This post has 0 comments

Easy to learn, difficult to master

Ruby is an incredible language. And likewise, Rails is an incredible framework. They’re both really easy to get up and running with. However, there’s a colossal difference between being able to write Ruby or Rails code and mastering Ruby or Rails code.

Ruby is complex

Ruby is, without question, a complex language. But you can certainly use Ruby without it seeming that way. Getting accustomed to all the semantics of containers, blocks, iterators, its true OO capabilities, and so on, does not mean you know Ruby. You may be able to use it, but that’s different. Any and every developer should be able to learn those things for any given language, and Ruby is no exception. Granted, it’s often easier in Ruby, though, because of it’s natural English-like style.

1
10.times { print "Ryan Heath" }

The appending if/unless conditions coupled with the punctuated methods always make for nice readability, too.

1
2
3
do_this! if stars_aligned?
do_this! unless end_of_world?
do_this! if stars_aligned? unless end_of_world?

It’s very easy on the eyes, which may be false advertising. A common misconception might be that the language is easy to master because of how intuitive it is. While that definitely helps, believe me, if you want to delve into the dark depths of what Ruby can do, you better know more than how to stuff an array or mixin a module.

Ruby is like a Mac. On the surface it seems so simple, but its true power is tucked down below a few layers, just waiting to be exploited. And that’s where the real fun is.

Rails can be sneaky

Rails provides an insane amount of assistance to building web applications. For the most part, it removes everything tedious and allows the developer to focus on the things that matter most. And that’s awesome. But you’re wasting your time if you think Rails is smart so you don’t have to be.

Sure, it has an ORM that means you can avoid writing SQL, but that doesn’t mean you don’t have to know and understand SQL. You still very much do. And relational databases altogether, for that matter.

Sure, you could easily generate a RESTful controller, but that doesn’t mean you’re adopting the RESTful architecture. That just means you know how to execute a command.

And probably worst of all, sure, you could write Rails code without knowing Ruby, but that leads to unexpected outcomes. The difference between Ruby and Rails would be lost in favor of a nasty cycle of trial and error. And ultimately, your code would suffer from it.

For better or worse, I think it’s fair to say that one could probably build an entire Rails application without really knowing what they were doing. Rails does that much. But eventually, you’d get bit.

I personally refuse to use a plugin or library without first examining the internals to make sure the code isn’t sloppy and that I understand exactly what it’s doing. If I don’t think I could write it myself, or at least modify it to tailor my needs, I won’t use it. I view that as cargo culting, and that is an awful way to write code.

Please, take the time to truly learn and appreciate all of the things that Rails does. Learn the framework, the idioms, best-practices, and most of all, learn Ruby.

Hypocrisy, perhaps?

I can’t claim these thoughts without owning up to the fact that, yes, I came to Ruby through Rails. And yes, I’ve built an application or two without truly knowing what I was doing. I’ve made those mistakes. Way back in the early days (and I think most developers go through this phase), I just wanted to make it work.

But after a few months of “making it work,” I began to care. I began to realize there were principles to follow, things to be aware of, and in general, better ways to code. And that’s when my life as a developer turned around. I started studying my craft, and have been for years now. I’ve read several programming books, and it’s safe to say that 80% of my feeds relate to programming and/or design.

And so far, all of that hard work has paid off tremendously, which is solid motivation to keep going.

Conclusion

Today, I’m quite comfortable with both Ruby and Rails, but that doesn’t mean I’ve mastered either one of them. They say it takes 10 years to master a language. I’ve been writing Ruby code for over 3 years now, and there are still times when I feel like I’ve not scratched the surface.

Ruby is a fun language and Rails is a fun framework. And while both of them may seem easy to learn, they’re quite the opposite to master.

Comments

Do you have something to say about this post?
Retype the image to the right Spam Hint: Are You Human? Textile Formatting Tips

or

Ryan Heath | Site Management A Ruby on Rails production.

This site is a Formed Function. Formed Function LLC | @formedfunction | Get in Touch