Hacker News new | past | comments | ask | show | jobs | submit login

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/

[1]: https://github.com/benhoyt/goawk




I 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.


"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"


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.


Perhaps; 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.


If your awk code is more than 20 lines, is it really cleaner?


AWK 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.


Yeah, 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.


Yeah, an a Z-machine (v3) in PostScript, but I woudn't write an IF interpreter in AWK.


> 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).


>Perl is widely known as a write once read never language for a reason.

From clueless Z-ers with no actual Perl experience, maybe.


I 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.


Question: 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?


ok, I found https://github.com/noyesno/awka so it is possible, though it uses it's own lib to link against - I don't know how much of that is based on AWK C vs original code.


AWK is an interpreter.


Awk has many interpreters and some compilers. awka is an awk compiler. lawk is an awk-JIT.


hence "compile" in quotes, and mention of AWK-lib instead of AWK. Ultimately, interpreted AWK will still call compiled machine code, no?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: