5 ms·
Namespaces (GNU Awk 5.0+) make Awk pretty well suited for larger projects (as demonstrated by aho), but it never quite took off; this article (by the author of
by bewuethr 5y ago
Namespaces (GNU Awk 5.0+) make Awk pretty well suited for larger projects (as demonstrated by aho), but it never quite took off; this article (by the author of GoAwk[1]) is a nice look at the relevance of Awk in 2020: https://lwn.net/Articles/820829/ https://lwn.net/Articles/820829/
[1]: https://github.com/benhoyt/goawk https://github.com/benhoyt/goawk
- anthk 5y agoDo not use AWK for that. Perl is best suited for that, literally. It was born as a better version of AWK. AWK is for tools less than 20 lines long. Anything more, use Perl, please.
- neilsimp1 5y agoYeah, but you gotta admit, this is cool. It may not be the most practical or useful thing, but it is cool that someone made Git in AWK.
- anthk 5y agoYeah, an a Z-machine (v3) in PostScript, but I woudn't write an IF interpreter in AWK.
- gompertz 5y agoPerhaps; but Awk is such a compact approach. My head feels cleaner when using it compared to Perl - perhaps as it's fairly close to C. The interpreter is a single binary on practically any OS, and is usually around 5MB in size. It's installed by default on essentially every OS (aside from Windows, which is an easy single exe download). Also with implementations like Mawk, it will destroy Perl in speed.
- anthk 5y agoAWK would work greatly well on plan9/9front, as most programs are short and really compact. On "big" Unixen (and I am an OpenBSD/Void user), for larger tools, Perl is preferred. On speed, that doesn't matter. Perl under OpenBSD has a pledge/unveil module, and it's used to write the package manager. Problem solved.
- maximus-decimus 5y agoIf your awk code is more than 20 lines, is it really cleaner?
- Chris2048 5y agoQuestion: could it be possible to translate/"compile" perl into equivalent AWK-lib version? Maybe I'm wrong, but I though perl code tended to be "higher-level", whereas AWK is optimised C throughout?
- krageon 5y ago> use Perl Perl is widely known as a write once read never language for a reason. In that sense I'll grant you awk is no better, but if you are stepping into scripting land you may as well use something generally readable (e.g. python, or just use bash).
- anthk 5y ago>Perl is widely known as a write once read never language for a reason. From clueless Z-ers with no actual Perl experience, maybe.
- dragonwriter 5y agoI am X-er whose first experience with Perl was working in enterprise software tech support in 1999 and diagnosing a crash due to a syntax that had somehow shipped in the install script for a GA product with a ~$100K annual license/support fee. While “write once, read never” is hyperbolic, it captures a real issue for Perl compared to many other competitive languages (of which, to be fair, there were far fewer widely supported for the tasks Perl was most often chosen for 20+ years ago.) That's not to say I don't find some things nice about Perl, and I’d love to be able to spend more time woth Raku which grew out of it.
- gompertz 5y agoI forget where I read it but Brian Kernighan said, at some point, the lack of namespaces in original Awk was probably the biggest mistake that prevented bigger adoption in large projects. Now that we have it, I'm hoping to see a brilliant IDE surface in the near future.
- maximus-decimus 5y ago"mistake" I read the book written by the creators and it's pretty clear they never intended it to be a general purpose language lol. I'm paraphrasing but they basically wrote in the book "People are completely mad and are intent on using our DSL as a general programming language so we added half baked functions to it but it's bad and you should feel bad"