Another Ruby rant

(I’m not sure if the first such rant was on this blog, or it was just on a comment in another blog, but it was about the incredibly navel-contemplating project “god“).

I like Ruby and I think its a neat little language. Although it still suffers from some childhood maladies (such as very bad performance), it has a very nice syntax and uses a lot of common development paradigms mixed-in in a very interesting and useful way. I’ve wrote a few programs (small and large) in Ruby and I keep it in my arsenal of programming tools on the same shelf as Perl (and not on the same shelf with Python which is stored in some box somewhere).

But I keep noticing the same problem – it used to be that we would joke about C programmers saying “when you have a hammer every problem looks like a nail”, but its becoming more and more apparent that Ruby programmers fall into the same category. Everywhere I turn theres someone who is trying to use Ruby (or misuse it as the case may be) in a situation where it is clearly the wrong tool for the job.

The above mentioned “god” is a good example, but here’s another one:

I was recently introduced to Rush which appears to be a unix shell that uses Ruby syntax. This is horrible on several levels (the least of which is performance) but its a great example of how Ruby’s syntax while great for implementing programming tasks from the very small to the very complex, is not a good fit for command line manipulation, just as its not a good fit for describing process monitoring configuration (see above).

The Rush web site contains a few example where the Rush syntax is better at implementing some shell task then some random (badly written) shell command. Which is OK (even taking into account that all these examples can be written better using some Bash or tcsh features), but still a far cry from claiming that Ruby syntax is better at any or even most tasks you do at the shell prompt.

As a simple example I’ll take an example from Rush’s main page, which appears to be exporting an SVN working directory to a remote server. Except for the futility of the practice as you can simple use svn export and complete the task without needing the local directory at all, here is for comparison the Rush code:

local = Rush::Box.new('localhost')
remote = Rush::Box.new('my.remote.server.com')
local_dir = local['/Users/adam/myproj/']
remote_dir = remote['/home/myproj/app/']
local_dir.copy_to remote_dir
remote_dir['**/.svn/'].each { |d| d.destroy }

And here is the comparable Bash code:

rsync /Users/adam/myproj/ my.remote.server.com:/home/myproj/app/
ssh my.remote.server.com '
for d in $(find /home/myproj/app/ -name .svn); do
rm -rf $d;
done'

I would hazard a guess that for all but the most shell-ignorant, the bash syntax makes more sense and is easier to write.

But what annoys me the most isn’t the fact that these Ruby guys keep coming up with (inferior) Ruby ways to replace some tried and true “legacy” methods, but the smugness in doing it. Just quoting from Rush’s home page’s comment for the previous task:

bash and ssh, we love you, but your era is past.

But I think I located the fatal flow here – as you can see from the example above, the user’s local directory is /Users/someguy, which is to say – the guy is using MS-Windows Vista as his primary operating system. Which suddenly makes things oh so clearer – yes, Rush is a superior shell if all you had to work with up until now is Windows CMD, Microsoft’s “Power Shell” and possibly cygwin. And if a hammer is your only tool, every problem looks like a nail.

2 Responses to “Another Ruby rant”

  1. Shlomi Fish:

    Isn’t /Users/someguy a Mac OS X convention? I wasn’t aware Vista had it this way.

  2. Guss:

    Indeed – Vista’s also uses /Users and I wasn’t aware that is was duplicating MacOS X in that. I still think that the guy is a Windows user but its also possible he is a Mac user, in which case most of my final argument goes down the trash.

Leave a Reply