Velato
The source code is a MIDI file. What counts is the interval between each note and a movable root, so a program can be composed, not just typed.
Daniel Temkin, 2009 · Turing complete: yes · ●●○ moderate · esolangs.org
The idea
Daniel Temkin made Velato in 2009. A program is a MIDI file, and only the pitch and order of the notes matter. Rhythm, dynamics and instrument are free. So the same program can be written as a march, a ballad or a jazz tune.
Read the story
The key idea is that commands are intervals, not notes. The first note of the program is the root. Every later note is read as its distance from the root: a major third, a perfect fifth, and so on. A command can also move the root, so the "key" of the program can change as it goes.
This makes programs singable, or at least listenable. Working programs tend to sound jazzy, because the commands force certain intervals together.
The machine
An imperative language with typed variables (int, char, double), while, if, input and printing. Each statement is a short phrase of notes, read relative to the current root.
| First interval | Statement |
|---|---|
| Major 2nd | Change the root: the next note is the new root |
| Minor 3rd | Let: a variable (one note), then an expression |
| Minor 6th | Declare: a variable (one note), then a type |
| Major 3rd | Blocks: then a second interval picks while, end while, if, else or end if |
| Major 6th | Special: then a perfect 5th means print, a perfect 4th or major 6th means input |
Expressions use their own intervals, where major and minor count the same. Numbers are one note per decimal digit, ending with a perfect fifth:
| Digit | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | end |
|---|---|---|---|---|---|---|---|---|---|---|---|
| Interval | m2 | M2 | m3 | M3 | P4 | dim5 | m6 | M6 | m7 | M7 | P5 |
A variable's "name" is a single note, so variables are pitches.
Example
Printing the letter A (code 65), read from the tables, with C as the root:
Printing the letter A (code 65), read from the tables, with C as the root:
C the first note: root = C
A major 6th: a special command
G perfect 5th: print
E 3rd: the expression is a value
F 4th: of type char, digits follow
A♭ minor 6th: digit 6
G♭ diminished 5th: digit 5
G perfect 5th: end of number
This is illustrative: it was read off the specification tables, not run through the compiler. Because only intervals matter, the same program starting on D (D B A F♯ G B♭ A♭ A) means exactly the same.
Patterns it teaches
- Camouflage: code disguised as music. Unlike Rockstar's lyrics, the disguise is not text at all.
- Encoding tricks: a relative encoding. The meaning is in the differences between symbols, not the symbols themselves, so a transposed program is the same program.
Try this
- Using the tables, write the notes for a statement that prints the number 42.
- Rewrite your answer with a root change in the middle, so it ends in a different key.
- Hard: install the Velato compiler, compose a two-statement program that sounds good, and run it.
Further
- esolangs.org/wiki/Velato
- Daniel Temkin's site, with a Hello World tutorial and MIDI files: danieltemkin.com/Velato
- Source: github.com/rottytooth/Velato
See also
Non-textual
Source esolangs.org (CC0) · Edit on esolangs.org