* What is it? No, not an OpenGL implementation in awk. It's a Lisp interpreter written in the AWK dialect understood by the One True Awk‡. I started by following directions from the [[https://github.com/kanaka/mal][MAL (Make a Lisp) project]]—which has an implementation written in GNU awk—but before getting far, I took a left turn into Nils Holm's [[https://t3x.org/lfn/index.html][_Lisp from Nothing_]] (ISBN 978-1-71650-883-7). ** ‡One True Awk? Yes—"the version of awk described in The AWK Programming Language, Second Edition, by Al Aho, Brian Kernighan, and Peter Weinberger (Addison-Wesley, 2024, ISBN-13 978-0138269722, ISBN-10 0138269726)." This is the [[https://github.com/onetrueawk/awk][One True Awk]], also known as BWK awk or ~nawk~. Importantly for our purposes here, this is the implementation of awk that is included in the FreeBSD base system. Around 1988, GNU awk, aka ~gawk~, was released; as is often the case with GNU programs, it has many more features, and it's made available under the GPL. Most notably, it has multidimensional arrays, of which the MAL Awk implementation makes heavy use; but the One True Awk doesn't have those. There are other [[view-source:https://en.wikipedia.org/wiki/AWK#Versions_and_implementations][Awk implementations]], but none of them are discussed here further. * What's it for? I envision deploying configurations to BSD machines with this. That's why it's so important that it work with the ~awk~ that's in the base system, rather than GNU awk. The [[https://wryun.github.io/es-shell/][es extensible shell]], based on Plan 9's ~rc~ but with first-class functions, does /beautifully/ at this job, but it has an occasional segfault, and errors in ~es~ scripts can be hard to locate, and it's not being maintained. A Lisp should be more readable, easier to improve, and more approachable. * Pull the other one, it's got bells on. Well, it seemed like a good idea at the time. There are other similar Lisp implementations: - the abovementioned GNU awk MAL implementation - [[https://github.com/chr15m/flk/][flk]], pronounced "fleck," is written in bash. - [[https://cliki.net/AWK%20Lisp][AWK Lisp]] ([[http://chasen.org/~daiti-m/etc/awk/walk.pdf][paper]]) from Roger Rohrbach, 1989. Using both the mal implementation in bash, and flk, I was immediately able to cause the sort of quoting problems that could lead to command injection. I don't remember now why I didn't just fix that. * All right, how do I use it then? See below on the language understood by this interpreter. ** Building and running - When under a BSD: Run ~make depend~, then ~make~. - When using GNU make: Just run ~make~. It will build all the source into one file, ~glotawk~, and run the tests. Then you can run that file, ~./glotawk~, and it'll show you a REPL prompt. ** Testing ~make test~ or ~make check~; either is the same. ** Enhancing and redistributing As detailed in the LICENSE file, this software is made available to you under the terms of the 2-clause BSD license. * How's it work? See [[file+emacs:doc/tour.org]] for more. * Contributing This code is kept in a Pijul repository. If you have changes or enhancements, talk to me on Mastodon @jaredjennings@mastodon.bsd.cafe, or email jjennings@fastmail.fm. Avoid constructs peculiar to GNU awk, GNU make, and GNU bash: not to be partisan, but to be minimalist. With luck, it might work on Busybox awk or some other even smaller thing. * More odd stuff https://j.agrue.info/, gemini://j.agrue.info * What dialect is this? So far it is mostly a LISP-1: functions and variables are in the same namespace. Macros are in a separate namespace, it is true; but people seem to say that, when you don't have hygienic macros, a LISP-2 (or LISP-N) is better. Well, for atoms, you get - ~true~ (not ~t~) - ~false~ - ~nil~ which equals ~()~ - numbers (which are Awk numbers, which in turn are double-precision floats) - double-quoted strings - interned symbols. For data structures, you get - pairs, like ~(first . second)~ - lists, like ~(a b c)~ Special forms are - atom - quote - car - cdr - cons - eq - cond - label - lambda - ... and a cast of dozens: all One Truue AWK functions are here. ~cond~ checks whether things are truthy, and that means not nil and not false. * Colophon Say "glow talk," or "glot awk," I don't care which. A polyglot is someone who knows multiple languages, and the One True Awk can be abbreviated as otawk. Some people may feel like Lisp glows. Also the word is short, and there are no indications from my favorite search engine that anyone else is using the word, so unique.