Skip to content

Maybe Ruby?

2010/04/29

A colleague of mine is a .NET developer with whom I have recently been having a conversation about the Ruby programming language. During our discourse, she sent the following, via email:

“I don’t know anything about Ruby except you can develop webpages with it… I manage 2 websites and am considering moving them to a CMS like Drupal — but maybe Ruby would be better?”

Here is the relevant portion of my response:

———————————-
It’s possible. A lot depends on who is managing the content. Here’s kind of a primer:

Ruby is a full featured, dynamically typed, Turing complete object oriented programming language.

It has a very rich standard library with Enumerable, Array, String, Fixnum, Date etc. classes that are based heavily on GoF patterns, and follow the principle of least surprise.

Another default feature of the language is the Interactive Ruby Buffer (irb) which presents a shell-like environment where a user can interact with the language. This is great, because Ruby has an enumerable interface, so you can do something like

irb(main):001:0> "Foo".class
=> String

… Ok, so “Foo” is a string. Then, you could use String.methods to find out the methods you can call on a string. Or, “Foo”.methods, because everything is an object in Ruby, and the inheritance chain makes very effective use of delegation.

So, Ruby is awesome, and it’s familiar because it’s object oriented, there’s very little cruft or overhead to the code due to the lack of static typing, so things like this work:

irb(main):002:0> foo = "foo"
=> "foo"
irb(main):003:0> foo.class
=> String
irb(main):004:0> foo = 3
=> 3
irb(main):005:0> foo.class
=> Fixnum

… note the lack of ‘var Integer foo = Integer.new’ type statements…

Excellent. We can type stuff into a console and get output. Wow, I’m bowled over. Completely floored. How is this not the Bash shell?

There are a TON of rapid development frameworks, written in Ruby, that make it an excellent fit for the web. Rails, Sinatra, Padrino, and Rails, to name a few (Rails being the predominant one, hence, it gets listed twice.) Think ASP.NET for Ruby, but with more opinionated architectures (MVC.NET is based on Rails, which uses an MVC architecture.)

Also, the tools and community support are unparalleled. There is a pretty ubiquitous package management system for Ruby called Gems which makes installing and using 3rd party libraries INSANELY easy (10 cent tour: $ gem install foo-library then require foo-library in your code). Also, the number of 3rd party libraries available is completely staggering, there are drop-in libs for authentication, authorization, searching, sorting, handling file attachments, testing, api integration (twitter, facebook, google,) well, you get the picture. Pretty much anything and everything you could ever conceivably need in an application, web or otherwise.

All thats needed is enough Ruby knowledge to glue them together, and you’re golden.

Ok so apparently, a cup of coffee and putting a quarter in me (by talking about Ruby/web) gets you a blog post via email.

Again, I firmly believe that a choice of language/framework for a given web application depends on a small handful of factors:

1. Who will be managing the content (what kind of UI do they need for editing copy and manipulating layout?)
– sometimes WordPress is enough to get the job done
2. How much custom functionality will the application require?
– if the answer is little to none, there’s probably a plug & play solution
3. How much time do you want to spend developing/deploying/managing
– if the answer is little to none, Ruby is probably a good fit.

———————————-

Blog post indeed. Ruby is my favorite language right now, and hopefully this will inspire you to check it out!

Advertisements

From → Programming, Ruby

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: