xonix's comments

xonix | 3 years ago | on: Why GNU grep is fast (2010)

Btw, the GNU awk is also considerably faster (due to bytecode) than awk bundled with BSD & Mac (usually, "one true awk").

xonix | 3 years ago | on: Perl is still relevant

When at some point I decided to learn AWK better, I was surprised to find that it had some very Perl-ish features, like `print` is the same as `print $0` or `if(/abc/){}` as shorthand for `if($0 ~ /abc/){}`, etc. Later I learned that Perl was designed as an AWK-on-steroids by Larry Wall.

No doubt Perl is much more powerful than AWK. But from other side it’s astonishing that such succinct and clear language as AWK was turned into a monstrosity called Perl.

Therefore, for me when it goes to text processing/manipulation I prefer AWK much better than Perl. Cleaner syntax, better portability, absolute minimalism. Now, thanks to GoAWK [0] CSV-processing with AWK is a piece of cake too.

I personally see no reason nowadays for me to write any Perl code, but I’m totally fine to use the software written in it.

[0] https://news.ycombinator.com/item?id=31350550

xonix | 4 years ago | on: Frawk: A fast, JITted, statically-typed AWK written in Rust

>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

xonix | 4 years ago | on: Frawk: A fast, JITted, statically-typed AWK written in Rust

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

xonix | 4 years ago | on: Welcome to C# 10

There is Awk - fascinating mini-language almost unchanged for decades. Therefore very portable. You can learn it once and be sure you know it all.

xonix | 5 years ago | on: How to do things safely in Bash (2018)

I personally have found that AWK is a surprisingly good alternative to shells for scripts bigger than average.

Why?

1. Portability (AWK is a part of POSIX)

2. Very clean syntax

3. Powerful associative arrays

4. Super-powerful string manipulations facilities

5. Easy shell interoperability

As an example here is a simplistic build tool [1] I’ve developed in AWK. As you can check [2] it runs unchanged under Linux/macOS/Win (via Git Bash).

[1] https://github.com/xonixx/makesure/blob/main/makesure.awk

[2] https://github.com/xonixx/makesure/actions/runs/702594092

xonix | 5 years ago | on: Mastering Jq: Part 1

I myself am developing a very similar tool [1] with somewhat saner (IMHO!) DSL. In fact this is a side-project from a JS lib I developed long ago [2].

My approach uses very simple ideas and is heavily based on JS internally. This is simple once you understand it [3] (thus saner DSL) and gives the whole power of JS in your hands.

I've also prepared a basic comparison jq vs jsqry based on some examples in article [4].

It's worth noting that currently the CLI tool [1] is written in Java using Graal VM polyglot native image compilation. Thus HUGE executable size of 95 MB (sic!) because it bundles JS engine. I'm considering rewriting this to QuickJS by Fabrice Bellard [5]. This should make it MUCH smaller.

[1] https://github.com/jsqry/jsqry-cli

[2] https://github.com/jsqry/jsqry

[3] https://jsqry.github.io/#filtering

[4] https://gist.github.com/xonixx/d6066e83ec0773df248141440b18e...

[5] https://bellard.org/quickjs/

page 2