Librarian of Alexandria

My mother recently wrote a poem warning against eating her food—-as she is not known to be a prolific cook—-and posted it in the kitchen. It went like this:

He who eats here\ Must trust his fate\ To please his palate\ And fill his plate\ Sometimes there is\ Sometimes there ain't\ I'm not a cook\ I like to paint

I responded to this abomination with a poem of my own:

I found the bane of Euterpe\     one dismal winter day\ A poem so bereft of skill\     I thought my mind would fray\ Into a million tiny threads—-\     it would have been more pleasant\ Than living with its memory\     as I do in the present.

For in the many brilliant years\     when poems were composed\ No single dumb, ungainly fool\     had ever yet proposed\ To write a poem with such a rhyme\     to make the muses faint\ And throw decorum to the wind\     by rhyming “paint” with “ain't.”

#stories

Isaac [Newton], though better equipped than Daniel or any other man alive to understand Relativity, showed no interest in his pie—-as if being in a state of movement with respect to the planet Earth rendered it somehow Not a Pie. But as far as Daniel was concerned, a pie in a moving frame of reference was no less a pie than one that was sitting still: position and velocity, to him, might be perfectly interesting physical properties, but they had no bearing on, no relationship to those properties that were essential to pie-ness. All that mattered to Daniel were relationships between his, Daniel's, physical state and that of the pie. If Daniel and Pie were close together both in position and velocity, then pie-eating became a practical, and tempting, possibility. If Pie were far asunder from Daniel or moving at a large relative velocity—-e.g., being hurled at his face—-then its pie-ness was somehow impaired, at least from the Daniel frame of reference. For the time being, however, these were purely Scholastic hypotheticals. Pie was on his lap and very much a pie, no matter what Isaac might think of it.

—-Neal Stephenson, “The Baroque Cycle”, Vol. 3: “The System of The World”, Book 7: “Currency”, p. 457

#quotes

He knows that there are in the soul tints more bewildering, more numberless and more nameless, than the colours of an autumn forest... Yet he seriously believes that these things can every one of them, in all their tones and semi-tones, in all their blends and unions, be accurately represented by an arbitrary system of grunts and squeals. He believes that an ordinary civilised stockbroker can really produce out of his own inside, noises which denote all the mysteries of memory and all the agonies of desire.

—-G.K. Chesterton

#quotes

... getty: I think the deal is men often have to go ▁▂▃▄▅▆▇█▆▃▁ ▂▃▄▅▆▇█▆▃▁ getty: And multiple orgasms would let them go ▁▂▃▄▅▆▇█▆▄▄▅▆▇█▆▃▁ getty: HA! I knew I could somehow represent that concept in Unicode. getty: Just THINK! While I was doing that, OTHER people were having ACTUAL SEX!

#stories

I've had an idea kicking around in the back of my head for a while, and I finally got around to making a working prototype (which I will probably end up deciding is the final version, at some point.) It has to do with generating random words based on grammar rules, with an emphasis on making certain things more likely and generating 'average' words. It came out of early D&D playing, where I wanted to have a consistent set of phonologies for every fake language that D&D had.

It is called Matzo, because I asked a friend for a random name and that's what she said. She also suggested, among other things, Yoko, but I decided against that.

Here's the basic idea: the following is verbatim a Matzo source file, which I have saved as aquan.mtz for testing:

word := syllable . syllable . (6 @ (syllable)); use word; syllable := 2: vowel | vowel . “'” | 4: consonant . vowel | consonant . vowel . “'”; consonant ::= p t k h wh l m n ng r w; vowel ::= a i u e o;

These statements can be in any order, and whitespace isn't significant except as a separator for certain tokens, so you can format/arrange the lines however you want. There are three kinds of statements:

  • use statements tell you which rule is going to start. If you omit one, it won't run. If you have two, it picks the first one.
  • Normal assignments (represented by :=) take an expression that contains a mixture of disjunction (a | b), concatenation (a . b), weighting (5: b) and repetition (5@(b)) and which can be parenthesized. Expressions also include both literals, which are surrounded by quotation marks, and identifiers, which refer to other rules.
  • Literal assignments (represented by ::=) which differ in that they are assumed to have a space-separated list of literals, possibly with weighting. This was for the common case where you want one rule to contain a simple disjunction of literals, such as consonant and vowel above.

A lot of these things are shorthand for other things—-really, all you need is concatenation, disjunction, and literals, and you can do most everything. The syntax 5: foo is shorthand for foo foo foo foo foo, so it is used to make an option more prevalent in a disjunction. For example,

vowel ::= i u;

chooses i and u about as often, whereas

vowel ::= 9:i u;

will choose i nine times out of ten.

The syntax 5@(foo) is another shorthand, somewhat less useful. The statement

word := 3@(syllable);

is equivalent to

word := syllable | syllable . syllable | syllable . syllable . syllable;

and is used in many various circumstances in my grammars, although it's less useful in other circumstances.

There are still problems with my implementation, which I am going to fix and put up on Github, but the grammar shown above (and others) work correctly. This is an idea I've had for ages; I can't believe it's taken me so long to sit down and write it, especially as it took no time at all. (I did the whole thing while an autograder was running for something I was grading.)

Here's an example of running the above file:

[getty@arjuna matzo]$ ./matzo aquan.mtz nu'melamio'o [getty@arjuna matzo]$ ./matzo aquan.mtz hopuwho [getty@arjuna matzo]$ ./matzo aquan.mtz iloa [getty@arjuna matzo]$ ./matzo aquan.mtz nenopungau

It's not necessarily limited to random words, but it's lacking a lot of utility that would make it sufficient for other purposes, which I will eventually add. Still, as an example of what it could also be used for:

gender ::= man woman; hair-color ::= black brown red blonde pink; build ::= fat fit skinny; job := “doctor” | “lawyer” | “janitor” | “systems analyst”; description := “This ” . gender . “ is a ” . job . “ with “ . hair-color . “ hair and a ” . build . “ build.”; use description;

Running this yields:

[getty@arjuna matzo]$ ./matzo description.mtz This man is a systems analyst with brown hair and a skinny build. [getty@arjuna matzo]$ ./matzo description.mtz This woman is a janitor with blonde hair and a fit build. [getty@arjuna matzo]$ ./matzo description.mtz This woman is a lawyer with blonde hair and a fat build. [getty@arjuna matzo]$ ./matzo description.mtz This woman is a janitor with red hair and a fat build.

In the future: variables (e.g. reusing a single generated value) and predicates (e.g. pronoun(man) := he, pronoun(woman) := she for use in complicated expressions.) Still, I'm proud of how far it is with so little work.

#programming