Thursday, February 11, 2010

Mixing Ruby with C++

Today I mixed Ruby and C++. The description is perhaps a bit misleading, as I did not combine C++ code and Ruby code into a single program. Instead, I used Ruby to analyze C++ code. The issues under consideration: how often is "new" used, where is it used, and which classes are allocated?

With 'grep', I was able to identify the lines that invoke 'new'. 'grep' caught some false positives, and I hand-edited the files to remove obvious errors. Then I fed the results into some Ruby scripts to summarize the data. From there, I could paste the figures into a spreadsheet.

Ruby made the job easy. I could have used Perl, or even C# or C++. Ruby has good built-in support for string manipulation, and that's exactly what I needed for this job. (Perl's is *almost* as good. Perhaps I should say just as powerful but with a syntax I find harder to use.)

I spent a small amount of time (and effort) on tools to collect the data.That leaves more time to analyze the data and make decisions. This is the way it should be.


No comments:

Post a Comment