5 ms·
Do 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 mo
by anthk 5y ago
Do 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.