Confessions Of A Scripting Weenie

I’m a big fan of project automation. So it’s slightly embarrassing to admit that I really don’t have a proper scripting language in my toolbox.

What usually happens is that, depending on the task, I end up with a mixture of .bat files, command line tools, Ant build scripts and manual search-replace operations in Emacs. If I need to script anything that’s complex enough to make those tools inadequate (loops, conditionals, recursion, non-trivial state), I fall back on Java.

Hardly a complete toolbox, I know.

I’ve known this for a while, but recently I decided to actually do something about it. So, time to A) learn Ruby properly and B) brush up on scripting and data crunching in general.

I already had Programming Ruby (aka “The Pickaxe”) by Andy Hunt lying around, so I worked my way through that first to bone up on basic Ruby syntax. I won’t go into detail on this book, it’s already given a lot of praise in other places. Suffice to say, many consider it to be the standard reference book on Ruby.

Then I picked up Everyday Scripting in Ruby. While the target audience is actually testers and other “supporting, non-coder personell”, it works pretty well as a companion piece to the Pickaxe.

The Pickaxe uses a standard object oriented application development for its examples. Everyday Scripting on the other hand employs standard scripting tasks instead; ie. file system manipulation, data crunching, web scraping and the like. The material that teaches Ruby syntax and OOP in general is clearly intended for people without much serious programming experience and does feel overly verbose in some parts - but it worked well as a refresher and “double take” after reading The Pickaxe. Finally, the book goes into some syntax “rubyisms” that The Pickaxe glosses over.

Data Crunching is another book on scripting. This book is more language agnostic (examples are provided in Python and Java). Think of it as a cookbook of common data manipulation tasks. Topics range between plain text, xml, binary data, relation databases and more.

I particularly liked the section on regular expressions - it felt like one of the best introductions I’ve read on the subject. The examples are actually relevant (matching mail adresses, urls, phone numbers) as opposed to the standard silly pattern matching examples of “ab, abab, aab” (ad nauseum) that many other regex introductions opt for instead.

It’s not a thick book, but the material is compact. I also found I quite liked the authors’ dry sense of humor.

All of these books contain a fair amount of useful advice on programming in general. In other words, they feel very much in line with the other books in the ”Pragmatic Bookshelf”. The authors regularly branch off into insightful advice on general methodology, techniques and tradeoffs related to the code and examples in the books.

In short, I feel like I’ve put some new tools in my automation toolbox, but I still need to practise them a lot more. I particularly need to work on my regex skills!