Why Ruby Works

I recently wrote that I had begun drinking beer and coding in C++ again. I wondered about a possible correlation. I found one. Both can cause headaches. I’ve gone back to using Ruby, my favorite programming language and my birthstone.

Object oriented programming has intrigued me, has it has many others. It attempts to model the real world. An object has data fields called instance variables, and functions to run on the data called methods. Classes can derive from other classes. For example, you could have a Vehicle class, then a Car class derived from the Vehicle class – a car represents a kind of vehicle. The Car class would include all the functionality of the Vehicle class plus whatever else. I once joked that objects just keep going down forever, like the native American belief of turtles stacked on top of one another which support the world. While it might make for an interesting thought experiment, I must partially recant it.

I love Ruby. I’ve loved it ever since I started learning it. It started in Japan and has grown from there. It has a very elegant and uniform syntax. This happens because of its philosophy.

Ruby truly treats everything as an object. In most languages, if you want to get the absolute value of the number 5, you’d write abs(5). This calls the abs function with 5 as its argument. In Ruby you’d write 5.abs. This calls the abs method on the number 5, an object of class Fixnum. Fixnum itself derives from class Integer, which derives from Numeric, which derives from Object, which derives from BasicObject, which derives from nil. See the pattern?

All objects belong to a class. All classes derive from another class. At the least, they derive from the class called Object, and All objects derive from nil. In other words, all objects come from nothing.

To me, this sounds very Zen. It reminds me of the zero point experienced in deep meditation. All things come from the no-thing. This void energy contains infinite potential, and brings creation into existence. Ruby models this truth, and this makes the language work. A consistent philosophy produces a consistent syntax.

Why suffer needlessly? Use Ruby and meditate daily!