Felipe Cypriano

You're about to read

Why I Choose to Learn Ruby Over Python

A few months ago I was looking for a technology to run the server side of a iPhone app. And I had two in mind: Ruby on Rails and Django (Python).

Why not others options? I already knew Java and its web frameworks but I didn’t want to use any of them because Java needs a lot of RAM even for the most simple things and I don’t want a big server before I really need it. PHP I don’t like the syntax, it is ugly.

This post is not a technical comparison between the languages, it’s why I’ve chosen to learn one of them first.

The First Impression

Obviously before I learn any framework I need to learn the language it runs on. The first place I went was the language’s official site: Ruby and Python.

As a developer keen on design my first impression was a big point to Ruby. Ruby’s site is more beautiful, but this isn’t why it’s better. It is better because it is easy to find how to get started. I found quickly the language’s overview, the first things to do and where to go to learn more in each step.

While in Python’s site I felt lost, it has too much text and no explicit direction to follow. It’d be very good if Python’s site become more digestible for beginners.

Syntax, sugar is good

At this poins I’m much more familiar with Ruby than Python.

  • Ruby has blocks, I love blocks since I started programming with Groovy.
  • Ruby support ternary operator. E.g. beer.amazing_taste? ? me.drink : garbage.put(beer)
  • Python supports multiple inheritance. All my background is with single inheritance languages, I get scared with the idea of having multiple inheritance in my code.

And my favorite is Ruby’s similarity with functional programming. For example, looping over a collection by passing a block directly to a each method.

Ruby - Looping using blocks
1
2
3
4
5
pubs_in_dublin.each do |pub|
  if pub.has_good_beer?
      "I need to go to #{pub_name} in Dublin before I die."
  end
end
Python - Looping using functions or for in
1
2
3
4
5
6
7
8
9
10
11
def should_go_to_pub(pub):
    if pub.has_good_beer:
        "I need to go to " + pub_name + " in Dublin before I die."

pubs_in_dublin.each(should_go_to_pub)

# or

for pub in pubs_in_dublin:
    if pub.has_good_beer:
        "I need to go to " + pub_name + " in Dublin before I die."

The last and least thing is that I’m not sure if I like the idention as being part of the language.

Wrapping Up

As it’s clear by now, I’m studing Ruby. And in the future I’ll sure learn Python as well as other languages.

If you’re into Ruby on Rails you should check out Code School they have excelent courses, I’m in love by their teaching way: Learn by Doing. Other materials I like about Ruby [on Rails]:

I’d love to hear what you think. Let’s discuss and learn more in the comments.