Categories Uncategorized

Ruby and the don’t speek of the devil culture

As a constantly inquiring mind I don’t seem to rest with programming languages. As you know when the hype got me I took a look at the Ruby language. I was really impressed by the carry out of the project and the rails concept was exceptional. However while focused on the Rails framework and the 10m tutorials that require minimal coding, I actually didn’t learn a lot about the language itself. Not until last week that I got some free time to invest in learning Ruby. The outcome was : This language is not for me. It’s too superstitious!

In ruby you don’t go around calling names you don’t understand their powers. Silence is wit and silence is sometimes hard to maintain!

In case you are wondering what the hell I’m talking about lets meet this simple program:


a = -5.0
method = a.abs
I’m pretty sure that if we present the above code to 100 programmers (users of Ruby or not) will think that method is a reference to the method a.abs. I don’t know maybe I grew up this way! My mind is not oriented to see a.abs in the above code as a function call that results in method being 5.0. In Ruby you don’t go around calling names. You might stumble upon a method! And don’t you come up here and say that you can write a.abs(), too. That is what makes is even worst. If the language creates such an inconsistency (names of objects are references while names for methods calls them) it should at least try to make the programmer notice it by every mean. If you can write () at the end of methods you get the idea that () call it… that the parentheses are there and make a difference. While they don’t.

Maybe it’s just me but I find this inconsistency a very big issue. Magnified by the kind of use I think dynamic scripting languages are made for. In Python getting the reference of a function or method and passing it around as a parameter to other methods and functions is the same thing like doing it with variables. This leads to designing code with no worries, while in Ruby this is impossible. You have to always take care to determine what you are dealing with, and if you are indeed dealing with a method make sure you don’t mention it in a way that will call it. Calling a method is a very specific thing and the language should have an explicit way to do it.

And don’t tell me that this way the language can be used to write readable code and even worst don’t throw at me the usual examples like :


exit unless "restaurant".include? "aura"
5.times { print "Odelay!" }

and say that its almost English that even a non-programmer can understand! A programming language does not have to be English and we certainly don’t have to write code that is understood by a non-programmer. And even if they did understand the above silly examples that don’t say anything about what someone will understand if he look at the code of a real application written in Ruby.

In Ruby you also have a a.length that is the same with a.size. This happens with all the classes and is a design decision! I agree that this allows you to write code easily (if you are a programmer that is! If you are not you can’t write code in any language) because of all the duplicated definitions. This is only helpful at the first week of programming in Ruby and is valuable only if you are so lazy to open the documentation. On the other hand the consequences of it when reading code is disastrous. Ruby people says that reading a code that once uses lenght to get the list’s number of contents while other times uses size makes nice and readable code. To me this is stupid and I would spend my time try to figure what is the one doing and what is the other. It took me some time to convince that both do the same thing!

Maybe its just me but I really don’t get Ruby!

Happy coding!

ruby,python

About the author