Montreal Tech Watch

This is a guest post from François Lamontagne, a Ruby web developer, or shall I say, a Ruby guru from Trois-Rivieres. There are some personal info about him in the first part, but the real deal is in the second part where he writes what are Ruby’s strengths

ruby

Hello Montreal Tech Watch readers!

Heri got in touch with me a few days ago and asked me if I would be interested to write an article on Montreal Tech Watch. I accepted right away!

Now I guess you wonder : Who’s that guy?

My name is François Lamontagne and I’m a 26 years old web developer living in Trois-Rivières. About 1 year ago, I came across a programming language that litteraly changed the way I look at programming in general : this language is ruby. If you’re a programmer, chances are you already heared about this language since it is the one behind the increasingly popular web framework : Ruby On Rails. I then realized something funny concerning ruby and ruby on rails : everyone seem to talk about it… but only a small percentage of people seem to use it… for real. In this article, my goal is to talk about the main advantages of ruby and why you should seriously consider using this language if you are a programmer. I will “try” not being too technical since I am aware that not every readers here are developers.

Ruby is not Rails

The first mistake people are doing is to confuse Ruby with Rails. Ruby is a high-level, general purpose programming language written in C (well, at least the official interpreter is written in C). It is a language interpreted, meaning that the instructions are parsed and executed at runtime. Most of the time, interpreted languages are slower but more flexible than compiled languages.

Rails is a web framework that was created to help developers build web applications easily and rapidly. To achieve this, a software architecture called MVC that existed long ago was crafted and inserted inside the framework to become its fondations. MVC stands for Model – View – Controller. It is a pattern (a way to develop an application) that force the developer to put his code into some predefined areas. The folks who created Rails decided to write the code of their framework in ruby… that’s why the framework is called Ruby On Rails. Someone could very well decide to rewrite the entire framework in PHP and call it PHP On Rails.

My blog : Ruby Fleebie

Ruby is one of these “new genre” programming languages that has a lot less constraints than other more traditional languages. I was so amazed by the beauty of the ruby syntax and by all of its possibilities that I decided to start my own blog (named Ruby Fleebie) in March 2007. Inside the blog, readers can expect informative and tutorial-like articles concerning the language concepts. I am learning Ruby everyday and the more I learn about it, the more I like it. I also learn a lot from the comments left by some very knowledgeable readers. Heck, I may be the one who write the articles, but it doesn’t mean I know more than everyone :)

I am pretty satisfied with the people reaction so far. There are about 650 readers subscribed to the RSS feed… not bad at all! Ruby Fleebie was also the main subject of an interview I gave to Peter Cooper, the maintainer of the reknown ruby blog : Ruby Inside. You can read the Interview here if you want. I hope I will enjoy maintaining Ruby Fleebie for a long time to come!

Why ruby rocks

Here is my personal reasons explaining why Ruby should not be missed by anyone :

#1 : Very expressive and readable syntax


3.times {puts "Ho! "} if person_speaking == :santa_claus

If you have some really basic experience in programming, chances are you understood the above instruction the first time you read it. Look how short this instruction is and how readable it remains. Note how there is no “looping construct” to write “Ho! ” 3 times. Instead, you just have to use a Ruby key concept called “code blocks” (have a look at this post if you want to know more about code blocks). Secondly, do you see where is the conditional operation? Yep! at the end of the instruction… and on the same line! Now read the instruction aloud and realize how readable it is. With some aesthetic changes, what you read is in fact : 3 times, puts ” Ho!” on the screen if the person speaking is Santa Claus. In another language, the above code could have look like this :


if (person_speaking == "santa claus") {
for (i=0; i<3;i++) {
print ("Ho! ");
}
}

Hmm… That certainly does the job, but I still prefer the Ruby way… not you?

#2 : Object oriented to the extreme

Unlike many other languages, we cannot just say that Ruby “is composed of” object oriented components. In Ruby, almost every single thing is an object. If you want to know more about that feature, I suggest that you read the following posts : 3 steps to understand how classes and objects work in ruby, Diving into ruby object model : Part 1, Diving into ruby object model : Part 2

#3 : Dynamic and open

In Ruby, a class is never “closed”. The developer can always reopen an already defined class to add a new method or a new attribute. Some “hardcore” developers don’t like that facet of Ruby because they feel it isn’t safe enough. What? That developer I don’t really trust can decide to reopen my class and remove/change my methods at runtime? That’s totally unacceptable! Well, that’s the price to pay for all the flexibility you have with Ruby. Ruby never tries to protect you from yourself nor does it tries to protect your code from other developers.

#4 : The “Ruby way”

Whatever the problem you are trying to solve, it seems that you can always do it “the ruby way”. You will know you did something “the ruby way” when you do it… it will smell ruby and feel ruby. Don’t worry however, doing something “the ruby way” absolutely doesn’t mean that there is only one single way to achieve something! You always have tons of possibilities… it’s just that some feel more ruby than others. I have started a new collection of posts on my blog that I called ” Rubyize this”. Readers have to change a (poorly written) code snippet into short and readable ruby. That is kind of fun actually.

There are tons of other reasons to try Ruby, but these 4 are the most important to me.

TimmyOnTime

I also want to talk about a project that I developed with Dan Simard, a web developer from Trois-Rivieres as well as a good friend of mine. The project is called TimmyOnTime. It is a time tracking tool based on instant messaging (Jabber, MSN or AIM). You write commands like “create project new website”, “start task build mockups”, etc and Timmy (the bot) will do the rest! We are extremely proud of what we’ve done. We have that amazing feeling of being the first to have done this kind of application. If you are curious and want to try it out, go here to get you started! I must warn you however that we are currently working on some stability issues with our robot… everything will return to the normal in the near future.

timmy  on time

90% of TimmyOnTime has been developed with Ruby On Rails, the other 10% (the bot) was written in plain Ruby. TimmyOnTime is another proof that Ruby and Rails are not only buzz words, these are efficient technologies that work for real.

Thanks for your time and I hope to see you on Ruby Fleebie!

if you are interested in programming languages, you might also check out the article about Scheme/Lisp, featured one month ago on Montreal Tech Watch

Comments

  • Heri August 13, 2007

    a few comments:
    - i am amazed that francois and dan simard are doing rubyfleeby and timmyonline from Trois-Rivieres.
    - also like he says, a lot of people assimilate ruby and rails, although there are other web frameworks like camping which are based on ruby. there are also many other frameworks which use the MVC model + Rails design pattern. Django and Cakephp comes to my mind.
    - timmyontime is interesting, as i think it’s the first rails site to interface with instant messenging. i might be wrong though.

  • macournoyer August 14, 2007

    Hey! nice article François, although nothing really new for me, I’ve been following your blogs for some time now!

    I’d put #3 as #1. As Ruby openness is the reason why it’s so readable and ensure you won’t never be stuck in a situation when you’d say: oh this can’t be done with Ruby.

    Keep on the good work Francois!

  • François Lamontagne August 14, 2007

    Thanks to both of you!

    Marc, that’s so true. Ruby is so flexible that I have yet to see a situation where someone is struck to the point of considering using another language.

  • Denis Canuel August 14, 2007

    To Heri: Please don’t forget that some coders work all the way from India :) Location doesn’t matter anymore..

    I’m glad to hear news from my hometown!

You must be logged in to post a comment.

blog comments powered by Disqus