esolang

CIOL

A brainfuck-like tape whose jumps count characters, and two commands that print the program itself.

Moon_, 2016 · Turing complete: yes · ●●○ moderate · esolangs.org

Tested with 5 known programs · Test method

Run it

Expected: Hello, World!

The idea

Moon_ made CIOL in 2016. It keeps a tape of cells like brainfuck, but control flow is different. [ does nothing at all, and ] jumps back to it while the cell is not 0, so every loop runs at least once. j and J jump forward or back over as many characters as the current cell holds.

Read the story

Two commands read the program's own text. r prints everything up to the next ; and R prints the next character. With them a quine is short work, and the specification has two by fizzie.

The machine

CommandDoes
p PMove the pointer up or down
+ -Add or take 1
o iPrint the cell as a character; read one
[ ]] goes back to [ while the cell is not 0
j JSkip forward or back as many characters as the cell holds
rPrint the program's text up to the next ;, then go on after it
RPrint the next character and skip it
/ \Store the cell in a register, or load it back
a s m dAdd, subtract, multiply or divide R1 and R2 into R3
*End the program

Any other character does nothing. The end of input reads as -1; the echo programs need that.

Example

The echo sets the cell to 3 and jumps over [-o to read first.

The echo sets the cell to 3 and jumps over [-o to read first. Each character is stored plus 1, so the -1 at the end of input becomes the 0 that ends the loop.

Expected: hello
Expected: olleh

The short quine prints its first three characters with R, builds a 24 with a loop and jumps back 24 to the r. That prints the middle of the program and lands on the last J, which jumps back again to the code that prints ;J.

Expected: +jrR+RjRr+++++[-p++++P]p_J----[-P+++p]P-oRJ*done;J

Patterns it teaches

  • Quine: a command that prints the source makes the quine a matter of jumping to it.
  • Turing tarpit: a brainfuck tape with jumps measured in characters.

Further

CIOL builds on Brainfuck.

Brainfuck derivatives

Cell-based

Write your own in Run Convert a program from CIOL

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: ciol.

Command line

shib run ciol -e '+++j[-oi+]' --input 'hello'
shib manual ciol

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/ciol.js

Docs: Kernel instructions · The .shib format · Command line · Adding a language

Source esolangs.org (CC0) · Edit on esolangs.org