esolang

UglyBF

Brainfuck with half its commands taken away. A backslash turns each one into its opposite.

2011 · Turing complete: yes · ●○○ easy · esolangs.org

Tested with 4 known programs · Test method

Run it

Expected: BF

The idea

UglyBF keeps four of brainfuck's eight commands, + > . [, and gets the other four back with \, which inverts the command after it. \+ is -, \> is <, \. is , and \[ is ].

Read the story

The sixth command is *, which doubles the command after it. Stars chain, so **+ adds 4 and ******+ adds 64. A \ passes over the stars, so \**+ subtracts 4. Any byte can be reached in at most eight groups, one for each bit.

The machine

CommandDoesAfter \
+Add 1 to the cellSubtract 1
>Move rightMove left
.Print the cellRead a byte into it
[Jump past the matching \[ if the cell is 0Jump back past the matching [ if it is not
*Double the next commandCannot be inverted

Every other character is a comment. The specification leaves the machine under it open. This implementation uses byte cells that wrap, a tape with no end either way and \. reading 0 at the end of the input. A doubled bracket is two brackets, which must pair up as in brainfuck.

Example

The BF.

The BF. ******+*+ adds 64 and 2, which is B.

The Hello World, in capitals. Each letter is reached from the one before.

Expected: HELLO WORLD

The specification writes the brainfuck program ,++[->++<]>[<+>-]<. in UglyBF. It reads a byte, adds 2 and doubles it, so 0, which is 48, comes out as d, which is 100.

Expected: d

Patterns it teaches

Further

UglyBF builds on Brainfuck.

Brainfuck derivatives

Cell-based

Write your own in Run Convert a program from UglyBF

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run uglybf -e '\..[\..\[' --input 'cat'
shib manual uglybf

Source

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

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

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