Day two of Ruby programming: (For now) It’s fun…

Day two of getting more into Ruby programming and I must say: Ruby can be fun! Okay, a few people seem to be really mad about it and see the language as an answer to everything, but I think there are some advantages to other languages, especially when it comes to string manipulation, iteration or string masking, but every language has its pros and cons.

Some programmers may say now, that there is nothing you can do in Ruby, you can’t do in another language and they’re right, but Ruby is clean, slim and really easy to read (if you know the syntax). The execution time of programs is almost similar to PHP programs with the same code and when it comes to huge amounts of data, PHP easily runs out of memory and you have to tweak the php.ini, whereas Ruby is running nice and smoothly.

It’s just nice when you can do things like

huge_array.each { |item| puts "Item: #{item}" }

to iterate an array and print out the content or

link = ''
puts "URL: #{#{URI.parse(link).host}"

to parse a string for a URL and just print out the hostname, done directly in the print statement.

But I also encountered some disadvantages of the language and facts against it:

  1. The amount of CPU and memory usage is much higher compared to PHP or Python and the runtime is almost similar, sometimes even slower.
  2. The syntax is unusual, if you come from languages like Java, C/C++ or PHP, where the syntax is more or less similar.
  3. Ruby is not spread as widely as PHP or Python are, which makes it hard for a business to make it the language of choice.

For now I think Ruby is a beautiful language which is fun to write, but it’s useless for business or complex applications. There are advantages, but they are not big enough to make you switch completely to Ruby. Most of the things can also be done in PHP or Python with not that much more effort or code – or fun…

Using Ruby or not is maybe more a matter of taste and available hardware resources, than of what you want to do with your code.

P.S. Some code will follow soon… šŸ˜‰

~ Image sources:

DieĀ Bergpredigt Jesu. Bild vonĀ Carl Bloch

Similar Posts: