Sebastian "blinry" Morr's language legit uses source control activity itself as code. While cards on a scrum board might be the common metric of progress in software development, to most programmers, their labor is more immediately symbolized by source control activity. You've completed piece of work, your PR is approved, and your feature branch merged into the master. Or, on a personal project, perhaps through direct commits.
Legit uses this symbolic labor of programming as its lexicon. To write legit code, one commits, creates branch creation, and merges. This essential part of most programmers' workflow that is not code becomes code through this language. In this way, it recalls esolangs like Nik Hanselmann's bodyfuck project, where programming labor is enacted, in that case as physical activity.
The initial impulse for blinry was to expand what can be considered code. They (blinry uses non-gendered pronouns) reference my Folders language as an influence:
I had heard of "Folders", and wanted to do something in a similar spirit - using a medium that was not meant for programming. A language that takes English descriptions of what to do, posts that on StackOverflow, waits for a few days, and then executes the best answer? A language based on knot theory? A cooperative language, which is meant to be written by two people at the same time? A language whose programs are positions on a Go board?
Finally a friend from home, https://chaos.social/@daniel_bohrer, provided the idea of a language where the program is described by the graph formed by commits in a Git repository.
Like Folders, legit ignores files and their content. This puts legit in the category of languages like Whitespace, which are almost designed for polyglot programming (meaning writing code that runs successfully in multiple languages) and easy to hide within those programs. In fact, an awesome future legit project might be to scan github for repos that are accidental legit programs.
Like other esolangs built on non-traditional media, legit maps a tree structure native to its medium to the structure of the Abstract Syntax Tree. In legit, this is the tree created by branches merging together. However, since the merges occur after the commits on those branches (branches merge together, they don't merge apart), blinry had to flip the order in which legit code is read:
Initially, I wanted the programs be executed in the order they commits were created: from the oldest commit to the newest. But I didn't find a good way of defining the order of "child commits" on a branching point that way. Deciding to do it the other way around, it got unambiguous, because merge commits clearly define the ordering of their parents.
Eventually blinry would use a bash script to automate program production, but at the beginning, they wrote Legit programs by hand.
blinry's notebooks for the language with working title "Gitlang"
A Legit Quine
When legit first appeared, in early 2019, it made the rounds on Hacker News, Reddit, and Twitter, and even sparked a debate if it's to be pronounced ləˈdʒɪt or ləˈɡɪt (blinry's response: "it's pronounced like 'gif.' :P"). The language made another round on social media later this summer when a quine appeared, written by a programmer with the handle remuladgryta.
Remuladgryta's quine is a bash script that performs the git operations necessary to create itself. It begins by introducing git aliases b, c, and m, for branch, commit and merge, but setting parameters to allow for commits with no changes and files with no data. This simplifies the quine but also, as an aesthetic gesture, reiterates the contentless nature of Legit, which eschews the text of code, using the activity of the programming its means of expression. Remuladgryta had not written a quine previously and found the work challenging at first.
I had a vague recollection that a common approach to writing quines is to create a program that takes some payload string as input and outputs a string-escaped version of the payload followed by the unescaped payload. I looked up some example quines in other languages to see if there were any pitfalls I needed to be aware of.
Reading through legit’s language spec it seemed to me that the stack+tape and available I/O operations would be enough to facilitate this approach fairly comfortably even as a novice without any real esolang or golfing experience.
Like blinry, remuladgryta created the first few iterations using pen and paper, with the idea of taking an input payload, then outputting both escaped and unescaped payloads, to print and to run (a common approach to quine-writing). While the paper scraps themselves are "lost to time," according to their author, here is a transcription of a pseudocode draft:
git commit “hello \”world\””
stack looks like:
pop, write, move-right gives tape =“dlrow…
pop, write, move-left gives tape = hello “world”
read, (escape), print, move-right -> tape head at right end of tape data
rewind tape head? Read tape in reverse and print in reverse?
At this point, it occurred to remuladgryta -- just as it had to blinry -- that the programs need to be written backwards, with the last commit being executed first:
Payload goes here
Fill the tape (right-to-left) with data from the stack
print contents of tape (left-to-right)
print 'git commit "\"'
read the tape onto the stack (right-to-left)
print each character on the stack, taking care to escape LF, " and
print the closing \""\n for the payload commit
My intuition told me that since legit exclusively uses the stack to direct program flow, the escape logic would be easier to write with the entire payload on the stack and not have to worry about the tape, so I went with that instead of rewinding the read/write head and read-escape-print each character one by one.
My last pseudocode iteration was to write down the actual legit instructions for each step in the previous iteration in a format that reads top-to-bottom yet is easy to convert to bottom-to-top git commands. I wrote this on my computer but unfortunately didn't keep this file. The first three blocks after the payload read something like this:#Fill the tape (right-to-left) with data from the stack
IF0: <empty commit message> | IF1: write 1 left [REVERSELOOP]
#print contents of tape (left-to-right)
PLOOP_ONE 1 right read dup
IF0: <empty commit message> | IF1: put [PLOOP_ONE]
#I knew I would need to double-escape special characters (once for the shell and once for legit) and I would rather have to worry about that only once, in the escape logic, so I decided to use the codepoints for \ (92) and “ (34).
#print 'git commit "\"'
PREAMBLE 34 92 34 " timmoc tig"
PLOOP_TWO put dup
IF0: <empty commit message> | IF1: [PLOOP_TWO]
In the final steps of creating the quine, remuladgryta discovered bugs in the quine but also in the language itself, which were fixed by blinry to make it fully working. In the best spirit of esolanging, the esoprogrammer was unknown to the creator of the language, but became a valued contributor by making discoveries about how it can be used.
Legit was developed at the Recurse Center in Brooklyn, where blinry attended a three-month session, among a group of peers called a batch. Blinry is quick to give credit to those who assisted with this idea, including batchmates who gave feedback on the idea as it developed, and helped come up with the name; his notes appear in this blog post.
- The legit homepage
- The final version of the quine
- A great intro to writing quines
- The Recurse Center
blinry also has a Patreon