Le Ralf, The Blog
All | Moods | Prog | Rants | Android | Projects | Trackday
Most recent entry: 2006-12-30 00:00:00 -- Generated on 2011-07-24 21:11:26 by Rig3 0.4-456
2006/12/30 Ruby
π 2006-12-30 00:00 by Ralf in Prog
I've been doing some Ruby again these last few days. I needed some scripts to do some server maintenance and writing them in bash looked too ugly. So I just rewrote them in Ruby and they look much much better.

Looking back on Ruby, the language is interesting. From an outside point of view it looks a bit clumsy sometimes -- for example @var constructs. There's also a lot of room for confusing syntax -- or better worded flexible syntax which can generate confusing code. One example is the fact that you can call a method without using parentheses. Pretty cool at first. If you come from any other language that means that at first your see a construct such as blah.foo and you don't know if foo is a member, a method, a variable, etc. Ruby's point is that the difference is moot. I don't quite buy it as we're dealing with procedural languages which work by generating side effects so you want to know when side effects occur -- and Ruby's answer to that is that foo! generates a side effect but foo should not. Well it may be.

In the end it's all a matter of conventions: learn the possible syntax and then decide what works for you and try to be consistent about it.

The libraries are also important and there are plenty around so they are not an issue.

Eventually maintenance in the long term is what matters. I'll see how it works. Python, with its ugly need to write self.foo all other the place, is at least very predictible and so far when coming back to an old Python scripts aeons later I had no trouble remembering how it worked and I could dive right in. I'm not quite sure about Ruby in this context, as even to remember some basics I had to look at other code I wrote 6 month ago and needed to open the book to remember the @var thing. However Python is too verbose to do shell scripting whereas Ruby can be as consise and cryptic, err I meant efficient, as one wants it too be.

Now don't get me wrong. I'm won't go as far as claim that Ruby is an acceptable LISP yet I'll claim that Ruby is good enough.


More pages: October 2008 June 2008 November 2007 May 2007 December 2006 August 2006 July 2006 April 2006 January 2006 December 2005 October 2005 September 2005 June 2005 May 2005 April 2005 March 2005 December 2004