Every few years I go and dig out a 65-line C program that I wrote as a grad student and try to gently poke it through a compiler but I finally got tired of that and replaced it with a 10-line awk script.
Wow, take a look at this jalopy! Written ca. 1977 (with ed(1), the standard editor) on a PDP-11/45 running V7, prob'ly on an ADM-3A "glass terminal" in the terminal room on the second floor of the E-Quad.
@peterhoneyman I remember you mentioning this program to me at one point while walking through the CSE building…16 years ago. Since then, I’ve occasionally thought about it.
@jeffpc I challenged Claude to rewrite it in awk and it came up with the same script that I wrote by hand.
Not sure what this means.
@jeffpc then i asked claude to convert that awk script to c and it introduced a buffer overflow lol
@peterhoneyman but did it use the 'register' keyword to make sure it is really fast at overflowing?
(BTW, I am amused by your usage of 'register' on argv. I know nothing about the calling conventions in V7 on PDP-11, so that smells like a silly attempt at an optimization that probably didn't accomplish anything measurable given that this program does I/O.)
@jeffpc yes, it is amusing in retrospect. iirc, twenty-something me had certain beliefs about the architecture he was dealing with, like “you have three general purpose registers available, use ‘em or lose ‘em.” obviously, the compiler can do a much better job allocating registers than some skinny long-haired chain smoking grad student lol. also, as you observe, this program will run at approximately the speed of cat(1) no matter what.
@peterhoneyman "use 'em or lose 'em" would be a cruel compiler code generation behavior :D