Presenting: "legit", my first esoteric programming language! Programs written in legit are defined entirely by the commit graph of a Git repository. You can find the specification, examples and an implementation here:

Execution starts at the commit pointed to by the master branch, and then continues backwards. The commit messages contain a simple stack-based language. If a commit has multiple parents, that's an if-else statement! Here's "hello world", for example:

Writing programs in legit is *fun*, because you have to write them backwards – the oldest commits get executed last! It's *educational*, because you have to learn some obscure command line flags, like "git commit --allow-empty" or "git merge --allow-unrelated-histories"!

It's *building character*, because if you make a typo, you'll have to redo all commits which come after that, as they will be based on the wrong commit hash. It's *mindful*, because you won't be able to track the program's history, as it already is a Git repo.

At, you will find two implementations: An interpreter (better suited for development and debugging purposes) and a compiler (which produces highly efficient binaries using LLVM). Both are written in Ruby. <3

legit is Turing complete! Here's a fully functioning Brainfuck interpreter to conveniently prove that. (Um, implementing that *might* have taken longer than doing the original language design…)

And just when I thought that might be a good final milestone, sat down next to me and asked: "Could you write a quine?" So here is my challenge to you, dear follower: Write a program in legit that prints the Git commands required to create itself. Good luck! 💚

@blinry so what exactly _is_ the input to legit? Is it the git graph, or is it the meta-language of shell commands to generate that git graph?

@blinry (on the other hand, one could describe the meta-language of git commands the "language" and the git graph the "compiled bytecode")

@daniel_bohrer I feel like a program printing the Git commands required to build itself would be a valid quine, but the programs are definitely the Git repos themselves! :D

@blinry @daniel_bohrer Ooooooooh! Nice idea!

Next Level: The program is written in bytecode and read from the commit hashes. The challenge is to produce the right hash while committing.
(Although you could ease this by defining a set of numbers to refer to the same instruction)

@blinry I’m both in love and scared to death, where do I sign up?

@blinry >A fun consequence of programs defined by a Git history is that you can’t properly track versions, because they already are Git repositories

You could commit it in a Mercurial repo^^

I wonder if you could make a language (actually I'm sure it's possible) that cares *only* about commit structure, and disregards commit messages etc.

@blinry I've been studying the language design. Was there a reason behind the decision to have multiple instructions per commit? Is this just syntactic sugar to make the program more concise?

@hastern Yeah, mostly that. Also, you can group instructions to logical units, I guess. And you are free to make one commit per instruction, after all.

@blinry I like how you can use the rest of the commit as comments explaining your thought process of the oneliner above, so it feels just like writing real commit messages ^^

@blinry do you have a goto sha1?

With that, you can do some very interesting things with inclusion of code from other git repos, once git has pulled the necessary libraries.

(Similar to my idea )

@joeyh There is a jump command, which jumps to the commit pointed to by a certain tag. But it would be easy to extend that to full-fletched SHA1 jumping, I think! :)

@blinry you... you monster




*boosts vigorously*

Sign in to participate in the conversation

The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!