Hacker News new | ask | show | jobs
by version_five 1074 days ago
My first thought when I saw this was that I'd like to see some stats on use of the three. I personally use sed and awk regularly and never perl, but I have no idea what is typical. I have a feeling that most people (amongst those who may have a use case) don't use any of them.
4 comments

Ditto - I use sed/awk daily, but I never write Perl any more (though I do use older bash scripts that call Perl under the hood).

I'm still comfortable recommending people learn sed/awk but I don't think I'd recommend learning Perl* now. It sits in an awkward spot between the simplicity of GNU utils and the expressivity of a scripting language, but doesn't do either of those things better than the equivalent sed/Python etc.

FWIW I still write Bash scripts on a daily basis, too.

* that's no comment on Raku, which I consider a separate beast.

> simplicity of GNU utils and the expressivity of a scripting language, but doesn't do either of those things better than the equivalent sed/Python etc.

It does scripting and gluing scripts far better than python.

It's not even close.

I'm not even going to address sed, awk, bash and the like.

Just imagine writing bash incorporating a sed script for something you can do with 20 keystrokes, then migrating the sed part to awk until it reaches 20 lines, then rewrite the whole thing to Python or somehow bridge it to the shell script - when you could have done the whole thing in Perl without feeling that it holds you back...
> without feeling that it holds you back

This. I always feel like bash and pipes are always holding me back and resisting.

Python is just to verbose to exec/pipe/read/write.

The real issue is the it's really easy to shoot yourself in the foot with perl.

if you have a script that makes heavy use of sed, awk, tr and the like, then maybe translating to perl would be most natural.

but otherwise a script is either just calling a lot of commands one after the other, for which a shell script is fine. or they do a lot of data mangling without needing many external applications or none even, in which case any other languages besides perl is just as fine.

Yep I responded in another comment but I use sed and awk almost daily but I never learned Perl. It's actually something that could be useful in my current role though -- is there a particularly good intro to Perl in 2023 that I might want to look at?
The Perl man pages are really good! Start with "man perlintro" and then look at whatever sections in the "man perl" table of contents fit your needs.

A lot of the tutorials online in my opinion are overbaked and written for people writing large OO projects using a lot of scaffolding. But the man pages were originally targeted at sed and awk users in your position.

Sounds perfect, thanks!
The wonderful thing about Perl is the docs from 2013 are still valid. All the growth/rapid-change/package-management issues that newer ecosystem suffer through Perl did in like the late 90s. 20 year old code still works (mostly). Not nearly the churn (anymore) as JS or PHP or Go or Rust.
Google Trends has sed crossing over perl about 5 years ago. Awk seems insignificant, which matches my expectation. (I’ve used sed but never awk, I don’t even know what it does)

Worth noting “sed” is “thirst” in Spanish, which has the potential to throw off the data, especially worldwide.

https://trends.google.com/trends/explore?date=all&geo=US&q=p...

awk is a fantastic command line application that is useful for filtering, basic computations and transformations that other basic utilities (e.g. cut, sort, etc.) + grep don't (readily/easily) provide. I suppose it might be a bit archaic these days, but for someone familiar with it, it's often faster to compose an awk command than to write even a very quick/short script in, e.g., python or perl, for certain things.
>awk is a fantastic command line application that is useful for filtering, basic computations and transformations that other basic utilities (e.g. cut, sort, etc.) + grep don't (readily/easily) provide.

All true.

But awk is also a programming language, not just a command line application or utility.

It has conditionals, loops, regexes, file handling, string handling, (limited) user-definable functions, hashes (associative arrays), reporting abilities and more.

In fact, the name of the original book about awk is The Awk Programming Language.

> In fact, the name of the original book about awk is The Awk Programming Language.

Great book. I read it after it was so enthusiastically endorsed here on HN. A lot of people said it was worth reading just to take in the excellent technical writing style of Brian Kernighan.

I would offer a strong second to that.

Cool. Yes, his style is good in his other books too, like K&R (C), K&P (Unix), and GOPL (Go), and The Practice of Programming.
it's not about stats but simply that the space between simple shell scripts and complex systems that required "big" language, which used to be filled by perl has shrunk a lot because it is filled with many other languages that are better suited for larger systems than perl is. for most uses of perl today there are a dozen other suitable languages, including some that are older than perl but were not freely available at the time.

stats wise i am sure there are still a lot of perl users. it has its fans, and there is a lot of existing systems, but it is now a choice among many, and not usually the best choice.

>for most uses of perl today there are a dozen other suitable languages, including some that are older than perl but were not freely available at the time.

Can you name some? I'm guessing Rexx is one of those you mean.

i am talking about the popular classics that have also been mentioned in other comments here, python, ruby, php, and several others that came after them.

with the older ones i mean languages like lisp and smalltalk which didn't become available for free or even usable on PCs until the 90s

i am not saying that they are all replacing perl, but that perl was used in areas where they are better suited, and with their appearance perl is no longer needed in those areas, hence the usage space for perl shrunk a lot.