Tuesday, 10 March 2015

The Uroboros and Other Quines

The 50-Language Uroboros
Eleven, Fifty, One Hundred Languages...

Something over five years ago, I described Yusuke Endoh's cycle of eleven programs - each of which, "written" in a particular computer programming language, prints out the source code - in a completely different language - for the next program in the cycle. Here, I have put the verb "written" into "so-called quotes", because in fact every program in such a cycle is auto-generated by the preceding one. So in fact, nothing at all need be "written", in the sense of "consciously composed" - half a dozen decent monkeys banging on a few old typewriters for a fortnight ought to suffice!

Just kidding, of course. Yusuke-san's achievement was and remains a very clever and unspeakably elegant construction. That its method of discovery can so readily be explained, and thence extended and generalised in various ways, detracts in no part from this.

The 100-Language Uroboros
Cyclic Cod Cosmologies

At the time, this extension of the Quine concept made me muse on the subject of Sims. The notion that our universe is "almost certainly" a simulation was trending highly at the time, and this cycle of languages seemed to lend the air of a Kekulé, benzene-ring "snake anecdote" to the previously hierarchical model of Sims creating Sims, creating Sims... and turtles all the way down.

For what if the laws of thermodynamics, working their random magic on the primordial "box of smoke" bestowed on us by an unstable vacuum, at some particular moment allowed the appearance of a configuration matching one of these Quines? Why then, wouldn't the subsequent evolution of the system be driven deterministically through the remaining phases, and eventually, back to that same starting configuration? In other words, the prime mover may be the ultimate effect, and we may well be products of creations we have authored.

Obviously this cosmology glosses over the fact that the laws of physics do not, in fact, appear to comprise a particular sequence of discrete, high-level computer language compilers and interpreters. Pah! Don't distract me with such trivial details!

Subsequent Developments

The original sequence of eleven languages went like this: Ruby, Python, Perl, Lua, OCaml, Haskell, C, Java, Brainfuck, Whitespace, Unlambda (and then back to Ruby). Then I missed a landmark in the development of this program cycle, because in 2012, Yusuke-san produced a 50-language variant demonstrating his complete mastery of the technique. Not so much by the sheer number of languages, as by the arbitrary character of his choice of "50" as a temporary stopping point, and the fact that all 50 languages are sequenced in alphanumeric order of language name!

Now there's a 100-language version, announced to the world on December 23rd, 2014 with the comment, "the 100th language: Lazy K. Merry Quine-mas!" This new dragon stretches all the way from A+ to Zoem and back, taking in all the Cs, sundry Lisps, Makefile, Visual Basic and LOLCODE among the many others along the way.

When you remember exactly what these programs do, the functionality disclaimer at the foot of the GitHub page is its own peculiar brand of comedy gold.

In Other News

Yusuke-san (@mametter) is also responsible - in collaboration with his wife Hiren (@hirekoke), whom he credits with teaching him Gingold, Monaghan and Lucy's SPH (smoothed-particle hydrodynamics) methods - for this almost-viral ASCII 2-D fluid mechanics simulator, currently doing the rounds: