Hacker News new | ask | show | jobs
by xonix 1585 days ago
I would kindly disagree here.

I myself been dedidacted Python lover in past for many years now came to a conclusion that what can be scripted with AWK, should be scripted in AWK (over Python, Ruby, Perl, etc.). I'm not saying that you should write big apps though, but for small scripts AWK is absolutely fine alternative to major scripting languages with lots of benefits. Been universally available (as part of POSIX) and very compliant (language standard is almost unchanged for over 30 years now). As they say: "Good programmer chooses the most powerful tool for the job, best programmer chooses the least powerful tool for the job". Also see [1].

There is absolutely nothing wrong in learning AWK. It's very small language you can grasp fully in hours or days, and be sure you know it all, since it's very unlikely it chanages any time soon. Besides the classical book [2] by A., W., K. is absolute pleasure to read. Amazing, but it's still totally relevant, despite been published in 1988.

Shameless plug. I'm the author of a task/command runner [3] implemented almost 100% in AWK and I still think this was perfect choice of a language for this project.

[1] https://en.wikipedia.org/wiki/Rule_of_least_power

[2] https://archive.org/download/pdfy-MgN0H1joIoDVoIC7/The_AWK_P...

[3] https://github.com/xonixx/makesure

2 comments

> As they say: "Good programmer chooses the most powerful tool for the job, best programmer chooses the least powerful tool for the job". Also see [1].

I don't agree with this. For a network protocol, sure. But not for what Awk does.

Tim Berners Lee's argument (in the Wikipedia page) does not apply to Awk.

> Been universally available (as part of POSIX) and very compliant (language standard is almost unchanged for over 30 years now).

There's tons of incompatible dialects. I think that shows the problem with what you're saying.

>There's tons of incompatible dialects. I think that shows the problem with what you're saying.

To my knowledge the major dialects in use are:

- One True Awk (aka bwk) (https://github.com/onetrueawk/awk) - this one is bundled in all *BSD/macOS

- Gawk (https://www.gnu.org/software/gawk/) - this one is bundled in most Linux

- mawk (https://invisible-island.net/mawk/) - bundled in some Linux distros (?), known as the fastest byte-code compiled implementation.

All three have very good compatibility, but Gawk is super-set over POSIX standard. I have some evidence here, since I regularly test [1] against these implementations and even some others, like GoAWK.

[1] https://github.com/xonixx/makesure/actions/runs/1830978431

I learned awk a while back, thinking along the same lines, and decided that there's a reason why everyone uses Python/Ruby/etc. nowadays when I learned that arguments and locals are the same thing. Even the designers of awk realize now that this was a mistake, as I recall. The rule of least power is a good guideline, but awk unfortunately has basic design mistakes that modern languages correct.
If you’re writing the kind of script that should be written in Awk, then the upsides will far outweigh that downside. Awk is not designed for 500-line, 50-function scripts, it’s designed for 50-line, 1- or 2- function scripts.