Why I use Ruby?


A few years back, for whatever reason, I needed a command line tool. Therefore, I started looking at the few of the scripting languages I knew about: Bash, Perl, Python, and Ruby.

Writing anything complex enough with options and everything is a pain in Bash, so I forgot about that one fast enough. Then I looked at Python and Perl … something about the feeling of the language, the way to use it and the code conventions broke the deal for me.

Even now that my job requires that I write in Python, even with the knowledge of the tools and libraries around the language, I still don’t like the language, the tools, and environment. In all honesty, it could have something to do with the fact that I use it on Windows … I assume even Ruby on Windows would be a pain.

Finally, I discovered Ruby. My first introduction to Ruby was through Build Awesome Command-Line Applications in Ruby. The book is basically a guide of how to write good command line applications. The author shows a few ways to handle command line applications in Ruby and ends up showing GLI. That library is the reason why I started investigating Ruby a bit more.

While playing with GLI to try to get a grasp of the library and the language, I bought a few more books and started to use Ruby for every little project where I could see it fit. A small list of the books I have can be found in the On my shelf (Ruby) section.

I’ve been using Ruby ever since, for every little thing I need to do. While I was writing my Master’s thesis, I even had a Rake script (think of it as a Makefile for Ruby, written in Ruby) to build every chapter and target different mediums.

I got lucky enough to be able to sneak a bit of Ruby in one of my past jobs. It was a C++ header parser that was used to analyze the classes and generate C++ classes to introspect the analyzed classes. For example, given a class:

Once the tool ran correctly, it would generate wrapper classes that would basically allow two things:

  1. Call methods by name;
  2. Access any member by name;

So you could run something that looked like:

It was used for generic serialization/deserialization of complex types. It worked quite well, for all the types we needed (native types, vectors, lists, arrays, other custom types, …). I was using treetop to parse the files and some custom code to generate the outputs. The parser did have a few limitations, mostly around C++11 constructs. But we simply decided not to use these in the parts of our codebase that needed the analysis.

I think that this is the gist of my first few experiences with Ruby. And you, which language do you really like/dislike? Why ??


Tagged . Bookmark the permalink.

Leave a Reply