Today was the first meetup of the Ruby-India group (I wanted to announce this on my blog yesterday but the net connection was down at home :|, <sarcasm>all hail Sify</sarcasm>). I wanted to attend the intro Ruby talk basically because Premshree yaks about Ruby so much, I realized it was better that I understood a bit of Ruby before I lost my sanity. Just kidding!
The meetup was at 4 pm at Avik’s office (Itellix) on Residency Road. First, we had the initial introductions from everyone – there were about 15 of us from many different companies. Yogi, from Thoughtworks, conducted the first session on coding in Ruby. He was mainly writing a program that works like the
find program in Unix and in the process, was demonstrating the syntax and features in Ruby. I didn’t understand some stuff like the use of :, @, @@ as prefixes to identifiers but I did get a brief understanding of the language. It sort of helped that I have a Python background but IMHO, a more formal first session that goes through the basics (like my ‘Slither away with Python’ presentation) would have been better for the newbies like me.
In-between Yogi’s session, lots of guys started coming in. Soon, there were about 30 people jampacked into the small room! I officially declared that we have achieved ‘closure’. Heh. When Martin came in, I looked at him, then turned to Premshree and then to Bret and thought “What’s with Ruby and guys with long hair ?!”… Oh well. Then, my colleagues Rajaram, Tahir and Suhas came in. Then, I realized there were 7 Yahoos in the room!
Next up was Bret’s talk on Watir and Selenium. Bret is also from Thoughtworks and is one of the guys working on the Watir and Selenium projects. Watir is an Internet Explorer-based tool written in Ruby for automated testing of websites. Selenium is a Thoughtworks-sponsored project also about web-testing, but it works across browsers and platforms (yes, it works on Firefox on Linux). Bret explained about how both of these software work and how they are designed. I was pretty impressed with their ease of use and the comprehensive testing that can be done.
The only drawback to Selenium is that it works best only when the websites are written with testing in mind. It won’t work for existing websites. Selenium is actually not Ruby-specific – it is more of an architecture and you can write programs for it in Python, Ruby, Java, .NET and other languages as well. Their website should have more details on that.
On the way back home, I kept thinking that I wasn’t convinced yet about Ruby. Most of the stuff I came across could have been done easily in Python. However, I believe in Alan Perlis’s statement “A language that doesn’t affect the way you think about programming, is not worth knowing.” So I wanted to know more about Ruby and try to ‘think in Ruby’ before actually thinking about its pros and cons and stuff.
Earlier, Prem had suggested that the Pragmatic Programmer’s Guide to Ruby was probably a good place for me to start. So, I opened it up and started reading. I wanted to try out the interactive prompt that was used to showcase Ruby all evening. As explained in the book, I used
$ locate eval.rb /usr/share/doc/ruby-1.8.1/sample/eval.rb</p> <p>$ ruby /usr/share/doc/ruby-1.8.1/sample/eval.rb ruby> a = 'Hello, world!' "Hello, world!" ruby> puts a ERR: undefined local variable or method `a' for main:Object
Yikes! I don’t understand what I’m doing wrong here. I hope the ruby-ers can help me out here? I haven’t even got past the preface of the book! I don’t know if this info is useful but I am using Fedora Core 3. Also, I don’t have
irb installed on my system.
Maybe Ruby doesn’t like me. Maybe snakes are friendlier than stones. Maybe ….
Update: After a
yum install irb, which also upgraded Ruby to 1.8.2, I have the ‘Hello World’ program running using
irb (short for interactive ruby).