Friday, April 8, 2011

Tips and tricks from "The Geek Stuff"

As a devoted command line user, I am always interested in learning new tricks to make my life more enjoyable. Recently, I came across Ramesh Natarajan’s blog “The Geek Stuff” which is full of “instruction guides, how-to, troubleshooting tips and tricks on Linux, database, hardware, security and web” to help solve practical problems.

For example, in the section “Best of the Blog”, I recently benefitted quite a bit by reading the following posts:
There are many other helpful tips/tricks as well; since I have bookmarked the site, I will surely come back!

Sunday, April 3, 2011

Scripting in Ruby is fun

Over the years, I have played around with various scripting languages, including awk, bash, Perl, Python and Ruby. By far, I have enjoyed Ruby the most; nowadays, I write scripts nearly exclusively in Ruby.

Created by Yukihiro "Matz" Matsumoto in Japan during the mid-1990s, Ruby became popular worldwide in mid-2000s, with the Rails web application framework. Indeed, I first dug into Ruby through Rails, and by reading David Black's book "Ruby for Rails; Ruby techniques for Rails developers". As an exercise, I implemented the current 3DNA v2.0 website with Rails v1.x. Then I quickly realized that the rapidly evolving Rails framework was beyond my time and interest to follow. However, I did begin to appreciate Ruby's simplicity, consistency and expressiveness. Over the past few years, I have collected over a dozen Ruby-related (e)books, including "The Well-Grounded Rubyist" (David Black, covering v1.9), "The Ruby Programming Language" (David Flanagan and Yukihiro Matsumoto), and "Metaprogramming Ruby: Program Like the Ruby Pros" (Paolo Perrotta). Just as my experience with (ANSI) C, I feel Ruby "wears well as one's experience with it grows" (K&R, in the preface of "The C Programming Language"). The better I know Ruby, the more I enjoy using it.

I recently wrote two Ruby scripts for the analysis of molecular dynamics (MD) simulation trajectories using 3DNA. Honestly, I would not have bothered with Perl for the task (otherwise, it would have been done long time ago), given the sideline nature of my support of 3DNA. Yet, writing and refining the Ruby scripts (with help of git and rake) have turned out to be a pleasant experience. Another reason why scripting in Ruby is fun is due to its large, active and friendly user community; there are many user-contributed libraries (gems) that serve well of common programming needs. As an example, in the 3DNA-MD scripts, I took advantage of the elegant Trollop commandline option parser by William Morgan. I picked Trollop among many other choices because it is self-contained in a single file, simple to use, and "gets out of your way".

In the Ruby community, exciting new developments are happening all the time. Recently, I was drawn to thor, "a simple and efficient tool for building self-documenting command line utilities". Over the past couple of years, I have browsed Sinatra and Sequel – they also look brilliant! Of course, for bioinformatics, there is the BioRuby project.

Overall, in my experience, scripting in Ruby is fun and exciting. Are you a Rubist yet?