scripting languages
Kenneth Burgener
kenneth at mail1.ttak.org
Mon Nov 8 10:21:07 MST 2010
Alex Esplin wrote:
> While it's true that you can write clean, easy-to-understand and
> maintain code in Perl, it takes more effort to do so than in Python.
> While it's also true that you can script anything in Python that you
> can in Perl, sometimes Perl's backtick (``) operator and built-in
> regex capabilities make it a lower-friction interface to automating
> system scripts.
I agree with Alex on the power of Perl.
I like to think of the transition like this: (depending on the size of
script I need)
Bash - Perl - Python
If the admin script is simple, I prefer to write the script in Bash.
With all of the nice linux tools already written, and used daily (grep,
awk, sed, cut, find), this is an easy choice. A bash script can be
whipped up in a matter of minutes, and is usually just a way to batch or
automate string of command lines that I could run manually.
If the script need is a bit more complicated and needs a little more
power, I prefer Perl. A lot of good Linux tools are written in Perl, so
this would be good to know anyway. Perls terse syntax, powerful regular
expressions, and CPAN are hard to beat.
If the script is turning into a full fledged program, Perl can do it,
but I see more and more larger projects moving to Python. Python is a
bit wordy for me, and stringing several external commands is more
complicated (very simple in bash an Perl), but Python does have good
readability and vast libraries, and is becoming the popular choice.
By the way, this transition logical also works for web development. I
like PHP for easy of use and quick development time. I like Perl for
sys admin stuff, but I would never use it for web development (even
though PHP is descended from Perl). For large enterprise applications,
Java and other tools may be more appropriate.
Of course, your mileage may vary.
Kenneth
More information about the PLUG
mailing list