JohnPhilipGreen said:
How do you pick which language to use for shell scripts? Ruby, perl, bash… is one a better choice for certain tasks, or does it just come down to which you like better?
How do you pick which language to use for shell scripts? Ruby, perl, bash… is one a better choice for certain tasks, or does it just come down to which you like better?
We’ve used so many where I work..
It is helpful to only use one language for all shell scripts—so you don’t have tons of code that can’t work together.
At one point, we used the same language for scripts that we were using for our web dev—so we could share libraries and not have to rewrite them in the scripting language.
In the end, this didn’t work well because PHP (and RUBY also) were not designed for shell scripting.
Soooo…..
The engineering decision would be based on some of the following criteria:
My opinion: Python is your best choice.
Since most scripting languages these days are able to do rapid, cross-platform development I find it more useful to work backwards and eliminate other languages.
Perl - not intuitive to learn - has a legacy of being difficult to maintain - community is split between v5 and v6 (this will likely be an issue for Python as well after 3.0)
Ruby - lack of unicode support in the base (though that is changing soon if not already) - lack of real momentum for anything other than rails.
3 criteria.
1. Is it suitable for the task? factors: speed, complexity of code.
2. Where will I use it? What is the likelihood that it is available on different machines?
3. Maintainability….will I have to revisit the code or is it a ‘one-off’ ?
For me:
sh/bash for simple iterative file manip.
perl/ruby for regex/text manip. (perl if regex is very complex or need it on different machines)
ruby for extensible or if oop is needed.
I agree with amanuel…
If the task involves issuing lot of OS related commands then bash/or any other shell script will do… Perl is so powerful, when it comes to regexs. But it has so many other intended purposes like effective CGI programs etc.,Ruby is relatively new & yet evolving dynamic script based OOP.