Magic

I know it's a cliché to liken programming to magic, programmers to wizards, but here I am, doing it.

Runes

A few weeks back I was chatting to a fellow co-worker about old languages. He was explaining that Old English uses a Runic alphabet rather than the Latin alphabet. Of course I knew what runes are, I've seen them before in content concerning Norse mythology (Skyrim/God of War et al.) but never thought about them in terms of English.

The revelation shouldn't have been too shocking given that English is a language that has Germanic roots, similar to some of the Scandinavian languages; which is a culture that most of us would associate with runes, Vikings & Norse mythology (and heavy metal).

Specifically, my colleague was talking about the letter "thorn" (Þ, þ) which is pronounced like "th" in "the". I was a bit mesmerised, not by the etymology of the letter but by the beauty of the glyph itself.

I mean look at it, it looks like magic!

Archmages

This got me thinking about how wizards cast spells. Sometimes it could be a somatic gesture, words of power or, in some cases, a written incantation. Wizards in lore are typically devotees of learning and wisdom, spending countless hours studying tomes and scrolls, learning the intricacies of their craft.

Sound Familiar ?

If you work in tech the answer is assuredly "yes".

Of course many professions, will too guide their practitioners through a similar unending journey of learning and discovery, but I can only speak from the experience of being a programmer.

You become proficient in a few areas that become your pillars. But if you stop reading what the latest trends, libraries, topologies & processes are, your skillet will atrophy and you will drift into irrelevance. This is not to say that you must know everything, in fact some fantastic programmers have a very small domain & tool set but they are able to use them efficiently and effectively in a way that really is magical.

These folks are your typical archmages. Controlling the universe with their deep knowledge of 1s & 0s. Unafraid of computer architectures and assembly. Maybe they've written a kernel, or dabbled in a compiler; they are the ones who build the lego blocks that the rest of us all play with, the ones who invent the spells.

Magicing

Programming, for me, is the literal transmutation of an idea into a thing. That thing may be a mere flash on the screen or the possession of a machine to beep and whirr, but it is a thing nonetheless, a mark left in the fabric of time; perhaps ephemeral but it definitely happened!1

I suppose every profession/hobby has it's own magic, musicians develop and speak in languages that evoke emotion, artists move between mind and media capturing the essence of fleeting moments or broad concepts. Scientists and mathematicians do the same thing but with logic and rigour rather than through emotion and beauty. Heck even lawyers exercise their own magic, using words & incantations to create binding pacts.

Nevertheless, programming feels to me like what I imagine a wizard feels when they are casting an enchantment; you (mostly) know all the concepts and ideas, but you have to weave them thoughtfully, layering primordial chords & concepts together to produce a complex harmony. It orders the chaos of the mind into neat and tidy little lines of code.

This last part for me is important and partially why I'm obsessed with the "aesthetic" of code, I like when it looks neat. I like when it looks ordered and clean2, and I like the idea that I am some arcane practitioner who can comprehend of truths and patterns that are hidden from the uninitiated and uninformed.

Runes

So what have I done about it ? Well I wrote a little 'wizard' cipher so I could feel as though I'm not mechanically cranking out the "n-th Fibonacci number", but instead casting an epic spell that will call into the void; navigating between what is and what might be, whispering into the ether in order to summon forth... er... the n-th Fibonacci number...

Essentially it's a simple substitution cipher, where I take the letters of the alphabet and replace them with runes.

It's a little bit of fun to pay homage the arcana of old mysticism & romantic notions of magic. I also spent a lot of time printing out the runes in rainbow color to really give it that "magical" feel.

Guess what animal spirit is summoned forth by the below incantation?3

ᚨᚬᚯᚮᚱᚳ ᚲᚸᚲ

ᚣᚤᚥ ᚥᚨᚡ(ᚭ):
    ᚨᚥ ᚭ <= ᚋ:
        ᚱᚤᚳᚴᚱᚭ ᚭ
    ᚱᚤᚳᚴᚱᚭ ᚥᚨᚡ(ᚭ - ᚋ) + ᚥᚨᚡ(ᚭ - ᚌ)

ᚯᚱᚨᚭᚳ(ᚥᚨᚡ(ᚨᚭᚳ(ᚲᚸᚲ.ᚠᚱᚦᚵ[ᚌ])))

Code

If anyone is interested in the code to generate (and run) the above, you can take a look at my repo here:

https://gitlab.com/reubentaylor91/runes

Bones

Essentially the bones of the cipher is just:

RUNES = "ᚠᚡᚢᚣᚤᚥᚦᚧᚨᚩᚪᚫᚬᚭᚮᚯᚰᚱᚲᚳᚴᚵᚶᚷᚸᚹᚺᚻᚼᚽᚾᚿᛀᛁᛂᛃᛄᛅᛆᛇᛈᛉᛊᛋᛌᛍᛎᛏᛐᛑᛒᛓᛔᛕᛖᛗᛘᛙᛚᛜᛝᛞᚠ"
OGHAM = "ᚚᚋᚌᚍᚎᚏᚁᚐᚑᚒᚓᚔ" 


def latin_to_rune(latin):
    if latin in string.ascii_lowercase:
        return RUNES[ord(latin) - ord("a")]
    if latin in "0123456789":
        return OGHAM[ord(latin) - ord("0")]
    return latin


def rune_to_latin(rune):
    if rune in RUNES:
        return chr(ord("a") + RUNES.index(rune))
    if rune in OGHAM:
        return chr(ord("0") + OGHAM.index(rune))
    return rune

Ogham

A little note here on the ogham letters. Ogham is a script that was used to write the early Irish language. It consists of a series of strokes or notches on a stone or wood. The ogham alphabet has 20 letters, each representing a different sound. It is not a numeric system, but I thought it would be fun to use it as a numeric representation of the digits 0-9, and it sort of fits, given it's similarity (superficaially) to roman numerals.

Reflections

This activity highlighted to me the fun of just creating and exploring an idea for the sake of it. Just pulling the thread to see where it goes and not worrying too much about the end result.

It also got me thinking about how programming languages are created. In the above, I'm just writing a python programme and encoding/decoding at runtime, not very magical in all honesty.

But what if I wanted to create a new language ? One that required I write runes rather than code?

It may end up looking like APL or J or K4, but in the end aren't all programming languages just as esoteric as every other language? Until we get comfortable with the arbitrary symbols and the rules that govern them we are all just staring at a wall of incomprehensible runes.

Isn't all language a weird form of telekinesis with weird noises and symbols that we have agreed upon to represent things in the world?

I mean, we have all agreed that the word "cat" represents a small furry animal with four legs and a tail. But what if I told you that in some other system, the phonetic pronunciation: "cat" means "a large body of water"? Both are equally valid, except that we have all agreed that the former is the "correct" one. It's correctness is based in it's utility to communicate a concept to another.

I digress, the point is not that language is arbitrary, but that the symbols we use to represent it are. I got to thinking about my new runix language and how I might go about creating it.

I am no arch mage, but this is something I've thought about time and again, though never have I been brave enough to dip even my toes into this divine wine.

There is a very good set of (free!) resources on Crafting Interpreters that I would recommend to anyone who is interested in creating their own language. One day I will read it and I will implement a little noddy interpreted language, I keep telling myself this but I never seem to get around to it. Too busy with my runes...


  1. Especially if you have logging enabled, then it's irrefutable and exists in the physical world as electrons trapped in a magnetic field inside your hard drive. 

  2. Even if the implementation is hot garbage. 

  3. Spoiler alert: it's the n-th fibonacci number

  4. What is it with the one letter language names guys, sheesh.