The most common question I get when talking to people who are new to scripting is Which language should I use?. The answer is of course is ‘it depends.’ One thing you want to avoid is taking someone’s answer as gospel. Everyone’s situation is different and they have their own biases. Here are some things off the top of my head you might want to consider.
- Do you know the language?
- Could you learn it?
- Is it supported on all your (current) platforms?
- Are those platforms all considered first-class citizens?
- Can it interact with your database?
- Does it control your other tools? (Selenium, Watir, etc.)
- Can you recycle code (Java jars or .NET assemblies) from elsewhere in your application?
- Does it support Unicode as a core data type?
- Is there seamless interaction with the operating system?
- Is there an active member community (to whom you can turn to for help)
Inevitably the answers to the above will lead you to Perl, Python and Ruby. Here is my take on each.
- Perl – Has been around forever (I’ve been using perl for more than half my life) and has been ported to every possible platform. There are tonnes of people to help you script and there is a wealth of libraries to do almost anything you can conceive. Perl code is also however known for being completely unmaintainable (if you are not really, really, careful).
- Ruby – Even though it may not truly deserve the label, it is the New Hotness (to quote Agent J from Men in Black). Most of the interest in Ruby seems to be a direct result of the popularity of Rails. If you are a Rails shop, then choosing this is a safe bet. I can only think of a handful of people I know who use it as a general scripting language though and the version 1.8 is the most prevalent in the real world (for Rails support) and it doesn’t handle Unicode/UTF-8 properly. 1.9 apparently does though.
- Python – Is known for producing maintainable code, has been ported all over the place and has lots of support for interacting with other systems (not as much as Perl, but more than Ruby). It is also easy to learn (which is a bit bonus). It is going through a bit of versioning pain right now as version 3.0 is not backward compatible with the 2.x versions so things are going to be a bit sketchy for a while with 3rd party modules.
Each has its own strengths, and weaknesses. I tend to recommend people learn Python really well and become familiar with both Perl and Ruby from a scripting context. And don’t be afraid to change languages if it is better suited for a particular task. Stubbornly holding onto a language when it is not the right one for the task is a trap people fall into too often.