Hacker News new | ask | show | jobs
by nmfisher 1514 days ago
Interesting take, but as someone who still works regularly with the shell, I'd say there is still a place for small core utils connected together with pipes/textual streams.

If we're talking parsing and chopping up text files, I can usually whip up something with awk/jq/cut/whatever in far less time than writing an equivalent Python script. There's a threshold where you prefer to switch to the scripting language for maintainability/testing, but the shell won't be going anywhere any time soon.

2 comments

Most awk/cut/whatever commands can be done with perl -ne in about 2x the keystrokes, but you don't need to learn the other tools.

In Python, the multiplier is much higher, and I could never get the oneliner stuff to work.

I don't understand why Python is touted as some kind of replacement for Perl when there are many things Perl does better and faster. Python isn't even optimised for one-liners so how can it be compared with Perl?
I moved from Perl to Python around 2011, mainly for Django.

Perl is a more expressive, "cleverer" language. But I noticed when I moved to Python that I write better code. Too often in Perl I would try something clever and terse, then two days later it would bite me in the bum and cause more problems than it solved.

I would still pull out Perl for some quick bash replacement type script, regular expressions are so much nicer in Perl, but for larger scale long term projects where maintenance is important, I would go for Python.

I use cut, grep, uniq, etc. a lot for processing largish files (multiple GB), but also use perl oneliners generously. Never took to awk for some reason. These days I write Go for anything larger than a oneliner, but I've added a lot of smallish Go CLI commands to use in pipes, too.
I agree with this threshold idea, and I would argue that Perl and probably Ruby also have a lower threshold for switching than Python. Nothing against Python.
Having moved from Perl to Python, there isn't really anything difficult in switching. I looked at Ruby too, which felt like a tidied up version of Perl, especially regarding