brainfuck 4 humans

From Esolang
Jump to navigation Jump to search

brainfuck 4 humans (shorthand bf4h) is a brainfuck derivative by User:David44 designed in late of January 2022 to make coding in brainfuck humanly easy. It is identical to brainfuck, but all instructions have been replaced with human-readable counterparts consisting of actual letters (e.g. incr instead of +). Additionally there are a few unique instructions that provide further ease for humans. bf4h is technically a member of the Trivial brainfuck substitution family.

Syntax

In its quest to "improve human readability and productivity," bf4h requires that all instructions be separated in some form. This can be a:

  • Whitespace (incr decr)
  • Colon (incr:decr)
  • Semicolon (incr;decr)
  • Newline (incr[newline]decr)
  • Tabs since 1.2 (incr[tab]decr)

Unseparated instructions (such as incrdecr) will be ignored, as "incrdecr" isn't an instruction.

Instructions

Current instruction set

bf4h brainfuck Description Version
left < Move the pointer left 1.0
right > Move the pointer right 1.0
incr + Increment the value of the current cell 1.0
decr - Decrement the value of the current cell 1.0
out . Output the ASCII value of the current cell 1.0
inp , Input character and stores it to the current cell 1.0
loop( [ Jump if zero (begin loop) 1.0
) ] Jump unless zero (end loop) 1.0
clr/clear [-] Clears current cell value (sets to zero) 1.2
set (char) [-](+ * ascii(char)) Clears current cell value then increments it by (ASCII value of char) 1.3
setn (number) [-](+ * number) Clears current cell value then increments it by (number) 1.3

Planned instructions (instructions that may or may not make it to a future version of bf4h)

bf4h brainfuck Description
repeat (n) (instruction(s)) taeper (instruction) * n Repeat instruction(s) for n times. Nested repeats will not be implemented

Implementations

bf4hc is the official implementation as designated by the (informal) spec that comes with it. It's a transpiler written in Python that outputs clean brainfuck.

Anyone is free to add their implementations.

Examples

Hello World

/* "Hello, World!" for bf4h 1.3+ */ 
set:H right 
set;e right 
set:l right 
set;l right 
set:o right 
setn 44 right /* , */
setn 32 right /* [Whitespace] */
set W right 
set o right 
set r right 
set l right 
set d right 
set ! right
setn 10 right /* [Newline] */
left;left;left;left;left;left;left;left;left;left;left;left;left;left
out;right;out;right;out;right;out;right;out;right;out;right;out;
right;out;right;out;right;out;right;out;right;out;right;out;right;right

Expected output: "Hello, World!"

/* 
"Hello World!" in bf4h
Translated instruction-for-instruction from the Wikipedia page for brainfuck
*/

incr incr incr incr incr incr incr incr loop( 
    /* These indents are not required, but recommended for readability */
    right incr incr incr incr 
    loop( 
        right incr incr right incr incr incr right incr 
        incr incr right incr left left left left decr 
    ) 
    right incr right incr right decr right right incr loop(
    left 
    ) 
    left decr 
) 
right right
out                                     "H"
right decr decr decr 
out                                     "e"
incr incr incr incr incr incr incr 
out out                                 "ll" 
incr incr incr 
out                                     "o"
right right 
out                                     [Whitespace] ASCII 32
left decr 
out                                     "W"
left 
out                                     "o"
incr incr incr 
out                                     "r"
decr decr decr decr decr decr  
out                                     "l"
decr decr decr decr decr decr decr decr 
out                                     "d"
right right incr 
out                                     "!"
right;incr 
incr
out                                     [Newline] ASCII 10
clr

Transcompilation through bf4hc would output:

++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.[-]

which prints "Hello World!"

Cat

inp loop(
    out inp
)
/* 
Equivalent to:
,[.,]
*/