to Ruby from PHP

I’ve been a PHP developer for years (well, around 3 years) and after reading so many bad comments on the web about PHP, I started to worry. I still love PHP though, but it’s not a crime to have another one to love. And by spreading love, we will learn more.

Picking up new languages doesn’t mean I will ditch PHP. I don’t think it will happen unless PHP die out. But probably will never happen as you still can see C around these days.

In my list is Java, Ruby, Python, and probably .Net especially C#. These are just a list, I don’t think I will be able to master all of them. But at least I will explore them all.

Let’s start from Java. I learned Java when I was doing my degree. So, it’s not a big deal for me to just pick it up again. Trying to do the similar thing I did perfectly well in PHP, I failed in Java. They are just different. Although I can still remember most of the syntax of Java, I have problem translating my PHP codes into Java. The problem is I can’t do associated array as easily as in PHP. It’s not hard, but I’m not familiar with it. So I gave up. Probably will come back next time.

Next is Ruby, browsing here and there, most of the talks are about Rails. But I want to start from Ruby. so I do.

Ruby is designed to be easily understood by human. The syntax is perfect just like spoken English. So cool that I can’t understand using my PHP mindset. Probably it was easier to learn C++ back then when I didn’t even know how to speak English well nor any holy languages called the programming language. Or am I too old to learn?

unless 10.is_a? Number
   put 10

The codes above is simple, isn’t it?. It is so easy to understand that I need to hit my head on the table several times to absorb it. Maybe I’m a fool, but this is the truth. When I read a code, I think in PHP language style, trying to get the TRUE and FALSE of the condition and then make decision. But when I first saw these lines, it took me to think for a while to apply my thinking style to this syntax. And this is just the beginning. I continue to read more about the syntax and I found this

def join( sep = $,, format = "%s" )
     collect do |item|
       sprintf( format, item )
     end.join( sep )

In my sense, this is a syntax error to have a double comma in a function declaration. End of story. But it’s not in Ruby… Game Over

Probably I should had given up, but Ruby’s uniqueness and differences from PHP that make me want to know more (not forget to mention that it’s also beautiful). It sounded like a love story now.

To learn Ruby, simple visit its website. You will find a lot of getting starter tutorials which are boring and some are fun. There is one that is ridiculous because it’s between telling a story and teaching Ruby. But it’s fun to read.


One thought on “to Ruby from PHP

  1. Pingback: Falling in Love with Ruby on Rails « Phelio Gnomi

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s