Hacker News new | ask | show | jobs
by oneweekwonder 1704 days ago
> Perl in 2021 probably seems like some curious antique like AWK

Sure you can call awk an antique tool being 44 years old, but its available on almost all unix-like systems even on router running busybox or bare minimum containers using alphine.

So its definitely a personal nitpick of mine calling a very relevant tool an antique.

4 comments

Awk is handy for bash programming. It's one of those weird tools in the box that is extremely useful in a very few specific scenarios, and that's what is keeping it alive.

No sane person is going to write an entire application in Awk anymore. But there are certainly 20 years old there who will encounter Awk while doing some command line data munging via SO and it will slowly become a tool in their toolbox.

Perl doesn't really have that. Sure you can ` | perl -e "..."` but honestly, I can do that with python/PHP too. I haven't encountered an SO answer for command line data processing hacks that have used perl in ages.

There is a book, "Minimal Perl", that is entirely about that usecase. I found it convincing, 15 years ago, and the only Perl I use are those terse command line snippets it teached, when others might use some combination of grep, sed and awk. I don't know if it is the best tool for the job, but it has worked for me.
I wrote an Awk script a few weeks ago precisely because I needed to filter some text. Python would be more verbose than I needed, Sed would become a write-only mess, but Awk in a Bash wrapper was just right.
Perl is much more than jq, but in the specific use-case of munging data on the command line, who is going to reach for Perl in a world of JSON APIs ?
AWK is sweet for big/streaming data analysis operations because by default awk/sed handle data without allocating memory. They're still highly used in these use cases just because it's typically easier to munge a gargantuan CSV file using command line tools that zip fast as fuck through it to get to the data. These tools come from days when malloc wasn't just an expensive bottleneck computationally, but expensive in terms of like 32MB of RAM or way less. If I need an application to get to data that huge (And there is PLENTY OF IT and more to come in these days, so it's pretty dope and groovy that this tool from the 70s is one of my best friends still -- care for your elders), I will get all modern or whatever and write one in go.
Somewhere, I've got a book for programming awk. It's got some really neat things in there that are non-trivial awk scripts from yesteryear.

I could see that being useful in the 70s or 80s... but not today. No-one writes awk more than a line or two today that's nestled in some ci script that is never looked at again.

Yes, the tool is ubiquitous - its everywhere. It also happens to be part of the standard of what is on a machine which keeps it being used for those two liners.

However, people aren't writing applications in awk anymore.

Similarly, perl is going to go the same way. It's going to be useful for those 10-20 line data transformations that are in some data pipeline for munging data. But its not something that's continuing to grow and find its way as a first choice.

Writing a new application in awk is something that people do for the exercise - much like going and doing your own primitive photography with a cyanotype. It's done as a "yes, I understand it enough to do this complex thing." Perl is a bit further back... it's developing your own film. There are still some people who do that as a matter of their business - but its not a first choice anymore.

Cyanotypes and doing your own darkroom work are things of antiques in today's age. They're not gone - but doing things in them is more like going to the pioneer town and seeing how it used to be done rather than a practical choice for today.

Applications in awk? No.

It's still a popular tool in the data processing realm. It's crazy to think that bash scripts using pipes is still one of the most memory efficient ways of processing file-based data. Even tools like Apache Airflow just went ahead and incorporated bash for this exact reason.

In the back of this 80s book that I've got somewhere there's a set of programs that are 5-7 printed pages long... and written entirely in awk.

A short example of that type of thing - https://people.sc.fsu.edu/~sshanbhag/awk-shell/histogram.awk

For the time, that was likely a very reasonable solution. But for today's world, there are better solutions.

It’s mature; i.e. done.