3 ms·
I used to love Awk! I still do, even if I don't use it much any more. Awk has a reputation for being hard to read (as noted in stevebmark's comment), but when
by Stratoscope 5y ago
I used to love Awk! I still do, even if I don't use it much any more.
Awk has a reputation for being hard to read (as noted in stevebmark's comment), but when I was using it actively, I tried to treat it as a serious programming language and write readable programs in it.
Several years ago I tracked down a couple of my old Awk programs from around 1990 and posted them here:
https://github.com/geary/awk https://github.com/geary/awk
SHANEY.AWK is an implementation of the infamous Mark V. Shaney:
https://www.clear.rice.edu/comp200/09fall/textriff/sci_am_paper.htm https://www.clear.rice.edu/comp200/09fall/textriff/sci_am_pa...
This was probably the first program that made me really impressed with Awk. People were writing rather complicated Shaney implementations in C, and I thought, "this could be really simple in Awk." And it was!
LJPII.AWK is the Awk program I'm most proud of. This was in the days when we had tiny screens and no multiple monitors and you always printed out your code to read it. In my circles we also fond of inserting "separator lines" between functions, in various formats such as this one:
// - - - - - - - - - - - - - - - - - -
So I wrote LJPII to print source code in "two up" format (two pages side by side in landscape mode) on my LaserJet II. It also converted the separator lines into graphical boxes, and tried to avoid splitting a function across multiple pages. It wasted some paper but made nicely readable printouts.
I wish I still had some of my old printouts, but they are long gone. One of these days I will have to see if I can update the code to work with the LaserJet emulation in my Brother printer! (It should mostly work, but I wrote this in the old Thompson Awk for DOS, so there are a couple of non-standard things in it.)
Looking at the code again, it's amusing to see some old Windows Hungarian notation which was popular/notorious back then, for example an "f" prefix for a boolean (flag) value, and "af" prefix for an array of flags.
Hungarian aside, I tried to make this code as readable as I could.
Random fun fact! Someone who used to be an avid Awk programmer is Will Hearst (William Randolph Hearst III). It's been many years since I talked with him, so no idea if he still does any Awk programming.