Hacker News new | ask | show | jobs
by Florin_Andrei 4172 days ago
> I used to hate Perl until I had to write some non-trivial shell scripts, then I realized Perl was a godsend compared to shell

If the job requires one page of code or less, use shell. If it requires more than one page of code, use Python or whatever. Simple as that.

I still hate Perl anyway - source code obfuscation by design is a terrible thing to do to your brain.

2 comments

> If the job requires one page of code or less, use shell. If it requires more than one page of code, use Python or whatever. Simple as that.

The problem with this simple guideline is that tools grow, so what was well less than a page becomes much more—and each small increment is too small to justify a complete re-write, so eventually you wind up with a huge shell-script monster.

That's mostly my heuristic as well, except there's a sweet spot for Perl somewhere in the middle.

Python has a upgrade problem. We're still running a bunch of CentOS 5.5 machines which depend on Python 2.4. In my org, we still have scripts littered around that expect a later version of python, but are executed from just "#!/usr/bin/python" instead of "python2.7". which fails on those old CentOS machines, on which you can't just set a newer version of Python as default because that'll break many system utilities.

Also, Perl's syntactic sugar for regular expressions turns out to be very useful (and I say this after years of grumbling against it).