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. |