What Perl can do better than Ruby and vice versa

Why Ruby?

Ruby is an incredible, relatively modern programming language. Ruby borrowed nice ideas from multiple languages, but mainly from Perl. Some believe, Ruby was so refreshing and cool that Larry Wall had no other choice than to start to work on Perl 6 to incorporate some Ruby ideas back into Perl.

We held the lecture "Introduction to Ruby for Perl programmers" on our October 2003 meeting. The lecture unveils basic Ruby ideas and syntax constructions. The slides are online and you are welcome to look through them for self-education.

Small Ruby snippet (no custom classes)

songs = [
    { "artist" => "Deep Purple", "title" => "Child in Time", },
    { "artist" => "Metallica", "title" => "Seek and Destroy", },
]

songs.each { |song|
    print song["title"], " (", song["artist"], ")\n"
}

Small Ruby snippet (custom classes)

class Song
    attr_reader :title, :album, :artist

    def initialize(filename)
        @artist, @album, @title = filename.split("/")[-3..-1]
        @title.chomp!(".mp3")
    end

    def play
        puts @title
    end
end

song = Song.new("/data/music/ABBA/The Best of/Chiquitita.mp3")
song.play

See more examples in the introduction lecture slides.

What Ruby has that Perl lacks

The following Ruby features are likely to be introduced in Perl 6:

What Ruby lacks

The future

Some of the missing Ruby features will be resolved in Ruby 2.

Perl 6 is a complete redesign of Perl 5 aiming to keep Perl relevant and dominant.

The future is going to be interesting with Perl 6 and Ruby 2 out.

References