Re:Frawk: An efficient Awk-like programming language. (2021)
by michaelcampbell on Monday April 22, 2024 @11:26AM
(#40115282)
The builtin CSV/TSV parsing seems the killer feature here, at least for me.
I've been using SQL on CSV and JSON lately as it's mostly easiest for me, but I can think back a few times where I've used an *awk for a specific need, AND had to deal with CSV parsing at the same time.
Re:Frawk: An efficient Awk-like programming language. (2021)
by mbivert on Monday April 22, 2024 @04:32PM
(#40119918)
Food for thought: have a look at this paper[0] about structural regular expressions. The author (Rob Pike) sketches in the last section an awk-support. I remember using such regexps a while ago to tweak indented JSON and JSON-like data (the indentation allowed to loop on hashes easily).
An awk with json support would for the most part need to be able to loop on hashes and arrays, and provide ways to travel in-depth. So far regular awk can travel through arrays (line-separator), and "in-depth" (e.g. nested "arrays") via regular loops & cie. Probably easier to think about it with a few concrete examples though.
Re:Frawk: An efficient Awk-like programming language. (2021)
by gpvos on Saturday April 27, 2024 @07:50AM
(#40179238)
I couldn't help the historian in me: looks like frawk gained CSV support in early 2020 with some bugfixes in July/August that year, while goawk gained it in May 2022, so my initial comment was correct.
Re:Frawk: An efficient Awk-like programming language. (2021)
by anthk on Monday April 22, 2024 @07:51PM
(#40126929)
>frawk is a small programming language for writing short programs processing textual data
AWK can do far more than that. With netcat you can write an IRC/Gopher client in days.
There are solitaries written in awk, even tetris and maybe, sokobans.
Re:Frawk: An efficient Awk-like programming language. (2021)
by gpvos on Saturday April 27, 2024 @07:58AM
(#40179286)
Interesting, I'd never heard of awka. Note that frawk does some JITting using LLVM, so it can also be very fast; but it also doesn't support everything that gawk does.
I've been using SQL on CSV and JSON lately as it's mostly easiest for me, but I can think back a few times where I've used an *awk for a specific need, AND had to deal with CSV parsing at the same time.
confirmed it by looking at the site just now.
You could probably use gron with awk pretty easily, since gron stands for “greppable json”.
But I also wonder how an awk with native json support would look like.
An awk with json support would for the most part need to be able to loop on hashes and arrays, and provide ways to travel in-depth. So far regular awk can travel through arrays (line-separator), and "in-depth" (e.g. nested "arrays") via regular loops & cie. Probably easier to think about it with a few concrete examples though.
[0]: http://doc.cat-v.org/bell_labs/structural_regexps/se.pdf
You mean only for strictly tabular JSON, i.e. no nesting beyond rows and columns?
AWK can do far more than that. With netcat you can write an IRC/Gopher client in days. There are solitaries written in awk, even tetris and maybe, sokobans.
https://github.com/TheMozg/awk-raycaster