What’s the deal with Ruby?


I read a lot of testing blogs.  TestingReflections aggregates a lot of these.  I've been seeing a lot of talk about Ruby.  By itself, I probably wouldn't take much notice, but I've often seen it associated with testers writing code (or script), which is something I think is extremely important for testers to be able to do.  I finally started to do a little reading on it.  As a big fan of Pragmatic Programming, I believe in learning a new programming language every year (or two), and thought that given its apparent growing popularity, Ruby would make a good choice.  I read through the docs and looked at some samples.


I don't get the excitement.


Sure, it's object oriented, sure it's powerful and (somewhat) simple.  But c# is all of those things as well.  Plus there are zillions* more samples of c# code.  I didn't see it spelled out as such in the docs I read, but the big win for Ruby is that it's multi platform enabled (and portable to new platforms).  I have no way of knowing the os demographic for ruby users, but as far as I can see, the only way it would be compelling is non microsoft platforms.  I realize as I write this that this sounds very narrow minded - my only confusion is regarding how someone writing automation only for windows platforms would find Ruby compelling (ok - windows platforms with .net framework installed - I may have answered my own question).


*yes, I made up this stat


Comments (5)

  1. Atilla Ozgur says:

    I think most microsoft SDET have more knowledge about programming languages than standart. In our company, our testers do not know any programming languages, yet they are excellent testers with combined experience of more than 12 years between two testers. Compare a hello world version of C# and hello world version of ruby. You will see that enterance to ruby world a lot easier than the c#.

    puts ‘hello world’

    save file as hello.rb

    ruby hello.rb

    on the other hand

    public class Hello1

    {

    public static void Main()

    {

    System.Console.WriteLine("Hello, World!");

    }

    }

    save the hello1.cs compile it with csc if you have no vs.net. If you have vs.net you need to learn what is solution, projects. What is console project etc. then run it.

    Ruby is more expressive than the c#. Period.

    10.times do

    puts "hello world"

    end

    5.upto(10) {|i|

    puts i

    }

    these statements are only beginning of ruby’s power. Yes it has no IDE, it is not considered enterprise. But ruby has other strengths than C#. C#’s design aims are different than ruby. VS.NET ide and C# is a wonderful programming environment but their use is not correct for everything.

    By the way, I am working as C# developer in my company. I am helping our testers to write acceptance tests with WATIR and ruby sometimes. I am MCSD.NET and I used ruby for 6 month,C# 2 and half year.

  2. Alan Page says:

    Thanks for the explanation – I see your point. I’m not (really) a c# programmer. I know C/C++ pretty well, and that’s made it easy for me to program in c# when necessary. To me, c# looked easier than ruby, and seemed more intuitive. I guess if you were starting from nowhere, ruby may be easier to get going with.

    I want to like ruby – I love that it’s getting non programming testers interested in programming. I guess I’m just not convinced that it’s a better choice than c# for those people.

  3. Alan Page says:

    I guess I should continue this a bit…

    I don’t use (and never have used) the vs ide – to me, it’s just as easy to run csc file.cs from the command line, then run the exe. I guess it’s an extra step, but not enough to scare anyone away. A newbie could get something like the snippet compiler (http://www.sliver.com/dotnet/SnippetCompiler/) and have all the setup work taken care of for them.

  4. I’ve taught over over a hundred testers to write Watir scripts using Ruby. They come in knowing no Ruby and in one-day they can be productive.

    There are two things about Ruby that allow this. First, it is a simple syntax without a lot of noise. Secondly, it has an interactive shell, so new users can type one line of code and then see what it does. Being able to see immediate results like this is a massive turbo boost up the learning curve.

    Once you’ve how to program through noise and deal with the compile cycle (as all C# programmers must), these may not seem like big things. But many testers don’t have these skills. Of course many programmers are finding that they also appreciate the clean syntax and tight cycles that Ruby programming provide.

  5. George says:

    ruby is more powerful than c# lets say you want to write an program that prints the sum of 1..5

    C#

    using System;

    using System.Collections.Generic;

    using System.Text;

    class Program

    {

       static void Main(string[] args)

       {

           int[] nums = { 1, 2, 3, 4, 5 };

           foreach (int i in nums)

           {

               Console.Write("{0} ", ii);

           }

           Console.WriteLine();

       }

    }

    Ruby

    puts (1..5).map{|x| xx}.join(‘ ‘)

    Dynamic vs static typeing

    Dynamic typeing reduces the nead for IDEs because in alot of cases you dont know the type pased into the method so you canot predict whats you can call on a preticuler object and the languige is more powerful so you can generate alot of the code you ben typeing in c# lets say you want to make an generic numerical algorithim like sum of list

    C#

    class foo{

     int sum(int[] x){

        int returnVal = 0;

        foreach(int i in x){

            returnVal += i;

        }

        return returnVal;

     }

    }

    Ruby

    module Enumerable

     def sum

       self.inject(0){|total,current| total+current}

     end

    end

Skip to main content