• Stars
    star
    138
  • Rank 263,006 (Top 6 %)
  • Language
    Ruby
  • Created over 5 years ago
  • Updated over 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An esoteric programming language where programs are defined by the graph of commits in a Git repository.

Programs written in legit are defined entirely by the commits in a Git repository. The content of the repository is ignored. legit is designed so that all relevant information is visible when running git log --graph --oneline, see the examples below.

Influences: Folders, Befunge, Brainfuck, Elymas.

Memory

In each legit program, two data structures are available: A stack, and a brainfuck-like endless tape, with a head moving on it. Both hold signed integers.

Control flow

Execution starts at the commit pointed to by the master branch. Commit messages can contain a series of instructions, seperated with spaces, which are executed one by one. Only the first line is considered, so lines after that can be used for comments.

  • If a commit has only one parent, execution will continue there after executing all instructions in the current commit.
  • If a commit has multiple parents (numbered 0, 1, 2, ...), the top stack element will be popped. If that element is n, to go n-th parent, or to the last one, if n is outside of the available range.

Instructions

For all instructions, popping from the empty stack will return a value of 0.

Control flow:

  • [<tag>]: jump to the specified Git tag. For example, [loop] will jump to the tag loop.
  • quit: stop the program.

I/O:

  • get: read a char from standard input and place its ASCII value on the stack. On EOF, push a 0.
  • put: pop top stack value and write it to standard output as a char. The value is always truncated to an unsigned byte.
  • <Number>: push the specified integer on the stack. For example, 42 will push the value 42.
  • "<Letters>": unescape string, then push the individual ASCII characters on the stack. For example, "Hi\n" will push the numbers 72, 105, and 10.

Stack operations:

  • dup: duplicate top stack value
  • pop: pop top stack value and discard it
  • add: pop two topmost stack values, add them, push result on the stack
  • sub: pop two topmost stack values, subtract top one from bottom one, push result on the stack
  • cmp: pop two topmost stack values, pushes 1 if bottommost one is larger, 0 otherwise

Tape operations:

  • read: place value of current tape cell on the stack
  • write: pop top stack value and write it to the current tape cell
  • left: pop top stack value, move tape head left for that many places
  • right: pop top stack value, move tape head right for that many places

Examples

legit comes with some examples: You can generate them like this:

make -C examples

Alternatively, you can also clone them directly from GitHub:

hello

A simple hello world program.

rot13

A ROT13 implementation.

brainfuck

A fully-functioning Brainfuck interpreter!

quine

This program outputs the Git commands required to create itself.

This doesn't actually exist yet. I challenge you to write it! :)

Implementations

This repository provides both an interpreter (better suited for development and debugging purposes) and a compiler (which produces highly efficient binaries).

For both, you'll need Ruby, and the "rugged" Gem:

gem install rugged

Running the interpreter

To execute a program, run

ruby interpreter.rb examples/hello/

Running the compiler

The compiler compiles a legit program to LLVM IR. You can then use LLVM tools to build binaries for all plaforms where you have a C standard library available (legit will be linked with exit, getchar and putchar).

First, run the compiler to create a .ll file:

ruby compiler.rb examples/hello/

And then, run a tool like clang to optimize it and produce a binary:

clang -O3 hello.ll -o hello

As an alternative to the second step, you can use the provided Makefile and simply run make hello.

License

The legit logo is a modification of Jason Long's original Git logo. The original as well as the modification are available under the terms of CC BY 3.0.

All other files in this repository are available under the terms of CC0.

More Repositories

1

habitctl

Minimalist command line tool you can use to track and examine your habits.
Rust
331
star
2

gish

Open Source version of the award-winning physics platformer
C
310
star
3

sliderland

A (very) minimalist creative coding playground. Make animations using only 64 HTML sliders!
JavaScript
187
star
4

wikidata-cardgame

Use Wikidata to generate fact cards on arbitrary topics!
JavaScript
64
star
5

nom

"Lose weight and hair through stress and poor nutrition"
Ruby
58
star
6

linux-puzzles

Linux puzzles (in your browser!)
JavaScript
39
star
7

nutsh

A framework for creating interactive command line tutorials, inspired by text adventures.
Go
31
star
8

vimboy

A dead simple personal wiki plugin for Vim
Vim Script
29
star
9

almightree

A jQuery plugin which makes large nested lists easier to navigate
JavaScript
21
star
10

wikidata-guessr

Guess the locations of random Wikidata items.
JavaScript
20
star
11

everything-exhibition

JavaScript
17
star
12

git-hydra

A tool that visualizes the internal structure of a Git repository in real-time. With snakes!
C++
17
star
13

json-explorer

Tiny browser for JSON APIs, especially ActivityPub
Svelte
15
star
14

dotfiles

My public Linux configuration files. See .README.md for setup instructions.
Shell
14
star
15

roboboy

A personal wiki for Android with Git synchronization
Java
14
star
16

glitchgallery

An online exhibition of pretty software bugs. Open for your submissions!
JavaScript
12
star
17

nelder-mead-optimizer

An easy-to-use Nelder-Mead optimizer for n-Vectors
C++
12
star
18

blinry.org

JavaScript
11
star
19

soft-drink-recipes

A collection of DIY soft drink recipes.
10
star
20

sillypond

Generates unplayable music in the style of John Stump's "Faerie’s Aire and Death Waltz".
Ruby
9
star
21

passivity-pub

Beginnings of a very lazy ActivityPub implementation
JavaScript
9
star
22

show-alt-text-userscript

A browser userscript that displays the alt text of images.
JavaScript
8
star
23

letterplotter

Generate map drawing from an address, for plotting on an envelope.
JavaScript
8
star
24

anki-fonts

Anki deck which will teach you to identify popular typefaces
Ruby
8
star
25

shader-workshop

An intro to GLSL
GLSL
8
star
26

advent-of-code-2019

My solutions for Advent of Code 2019. In Haskell! :O
Haskell
6
star
27

circus

Visualization tool for circle packing algorithms
CoffeeScript
6
star
28

cat-trees

Generative cat tree generator, using wave function collapse
JavaScript
5
star
29

mousetoy

Games with multiple mouse pointers
C
5
star
30

wurst-day-ever

2D puzzle game about repairing sausages
GDScript
5
star
31

anki-german-sign-language

Ruby
5
star
32

legit-brainfuck

4
star
33

compass-in-the-sky

A Game of Solar orientation
Svelte
4
star
34

clickbait

An action game where you need to close all popups. Made for GMTK Game Jam 2020.
GDScript
4
star
35

fake-java-println

Drop this into your coworkers Java project tomorrow
Java
3
star
36

1room

Lua
3
star
37

boids

GDScript
3
star
38

vimboy.nvim

A very simple personal wiki plugin – Lua version
Lua
3
star
39

map-of-rc

Map of the Recurse Center
Ruby
2
star
40

ten-little-letters

Compo entry for Ludum Dare 39
Lua
2
star
41

cg2

Lösungen der Aufgaben von „Echtzeit-Computergrafik“ der TU BS
C++
2
star
42

compass-belt-hardware

2
star
43

pomodoro-jukebox

Svelte
2
star
44

bachelor-thesis

"The Nut Shell – A Framework for Creating Interactive Command Line Tutorials"
TeX
2
star
45

x86-tests

Assembly
2
star
46

small-world

An explorable explanation about everything that's going on on Earth.
Svelte
1
star
47

operation-mindfuck-3

JavaScript
1
star
48

legit-hello

1
star
49

card10-north-sense

Python
1
star
50

gofuck

Converts Go games (in SGF format) to Brainfuck
Ruby
1
star
51

nessie

Barely working recursive DNS server written in Ruby. Made for the Recurse Center's "Domain Name Saturday"!
Ruby
1
star
52

stop-tree

Haskell
1
star
53

esolangs

Seminar paper about esoteric programming languages
TeX
1
star
54

pixelator

Shell
1
star
55

map.recurse.com

Web interface for the Map of RC
JavaScript
1
star
56

compass-belt-app

Java
1
star
57

time-barons

Shell
1
star
58

counter-ring

A 3D-printed, customizable counter ring.
OpenSCAD
1
star
59

tracery-bots

Tracery grammars of some bots I'm maintaining.
1
star
60

legit-quine

A quine for the legit programming language, written by LegionMammal978
1
star
61

nutsh-vorkurs

1
star
62

webboy

Compile a plaintext wiki to HTML
Ruby
1
star
63

operation-mindfuck-4

JavaScript
1
star
64

operation-mindfuck-5

JavaScript
1
star
65

rc3-wikipaka-clock

Lua
1
star
66

bloody

"A Bloody Small World" – a game for Ludum Dare 38
Lua
1
star
67

compass-belt-firmware

Python
1
star
68

tour.recurse.com

A virtual photo tour of the Recurse Center
JavaScript
1
star
69

minitools

Miniature tools for working with x86 assembly and ELF files
Rust
1
star
70

hungry-spider

GDScript
1
star
71

glitchgallery-3d

A prototype for an explorable 3D museum, showcasing images from the Glitch Gallery.
GDScript
1
star
72

recipes-demo

Repo for testing Git workflow and pull requests
1
star
73

etherwiki

Real-time coediting wiki etherpad thing
Svelte
1
star
74

shadow-yoga-instructor

A game about twisting your body, so that your shadow looks like letters. Bring your friends!
JavaScript
1
star