esolang

GotoFuck

Brainfuck without its brackets. The only jump is a goto to a line number, taken when the cell is 0.

VilgotanL, 2021 · Turing complete: yes · ●●○ moderate · esolangs.org

Tested with 3 known programs · Test method

Run it

Expected: abc

The idea

VilgotanL made GotoFuck in 2021. It keeps six of brainfuck's commands and replaces the loop [ ] with :n, a conditional goto. When the cell under the pointer is 0, :n jumps to the start of line n, counted from 1. When it is not, nothing happens. With no line number, or one past the end, :n ends the program instead.

Read the story

There is no unconditional jump. A program gets one by stepping onto a cell it knows is 0. Brainfuck translates into GotoFuck with every brainfuck cell at an even place on the tape and a spare 0 beside it. [ becomes :n> and a line break and <, and ] becomes :after>:n and a line break.

The machine

CommandDoes
+ -Add or take one from the cell
< >Move left or right
.Print the cell
,Read a character, 0 at the end of input
:nIf the cell is 0, go to line n; with no such line, halt

Everything else is a comment. The specification leaves the cells and the tape open; cells wrap at 256 as in brainfuck, and the tape grows to the right.

Example

The cat reads a character and halts if it is 0, which is what the end of input gives.

The cat reads a character and halts if it is 0, which is what the end of input gives. Otherwise it prints it and moves to a fresh cell, where :1 always jumps.

The truth machine prints its input and copies it into the cells two and four places away. A loop of 6 times 8 takes 48 from the first copy. On 0 that copy is 0, :7 names a line past the end and the program halts. On 1 it is 1, and the last line prints the other copy without end.

Expected: 0

The Hello World is 18 lines made from brainfuck by that rule, and it prints Hello, world! and a line feed.

Patterns it teaches

Further

GotoFuck builds on Brainfuck.

Brainfuck derivatives

Cell-based

Write your own in Run Convert a program from GotoFuck

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run gotofuck -e ',:.>
:1' --input 'abc'
shib manual gotofuck

Source

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

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

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