4 ms·
I don’t really see the proposition value other than runtime. For most awk commands the syntax is succinct and works well. This unnecessarily makes it much more
by andrewzah 5y ago
I don’t really see the proposition value other than runtime. For most awk commands the syntax is succinct and works well. This unnecessarily makes it much more tedious and verbose to… save time not learning basic awk syntax?
The awk manual is a pretty light read.
- jjtheblunt 5y agototally agree
- benhoyt 5y agoYeah, I don't disagree: > Should you use Prig? I’m not going to stop you! But to be honest, you’re probably better off learning the ubiquitous (and significantly terser) AWK language.
- cb321 5y agoThe Nim variant (yes, knowing Nim first matters) has terser syntax, but retains the strong typing that allows compiling to fast running code. E.g., from the rp --help, to total just the positive integers: rp -b'var t=0' -w'0.i>0' t+=0.i -e'echo t' Missing is the awk-like implicit declaration/number stuff (divisive "magic"), but 'var t=0' is pretty succinct. With more work the harness could possibly infer the type of 't' from parameters to eliminate the need for that. Just with backslash instead of single quote you can get it down to 39 bytes vs 33 for awk '{if($1>0)t+=$1}END{print t}'. If you have some CSV with headers you can cobble together something kind of like ghetto SQL: rp 'echo CustomerName,City' -w'Country=="USA"' < data Part of the value prop is that you can directly author/access any library code in your native prog.lang in your query as naturally as native imports and routine calls. Awk is pretty established and for small programs you may not need any libs, but there are a lot more Go/Python/etc. libs than awk libs, AFAICT. Beyond lib existence there is lib API understanding. There is not only language learning to be saved, but also lib ecosystem learning. I'm sure 'perl -na' folks could rattle off dozens of examples with CPAN package PDQ. I know many people who would say learning the ecosystem is what takes the most time... There is also little barrier to using a similar approach to "compile" your data as well as the code. This is basically how 'nio qry' works as a kind of open architecture ghetto DB. [1] { Yeah, yeah, Big Iron, corporate database XYZ probably also has some ugly, non-portable extension language with 1970s prog.lang aesthetics. } [1] https://github.com/c-blake/nio https://github.com/c-blake/nio