Home

Awesome

Backhand

Backhand is an esoteric language with an unusual program flow, inspired by 2D languages, such as Befunge and ><>.

Backhand is a 1D language, so most programs are interpreted as a series of characters. The origin of the name comes from "Back and Forth", since to get the most out of the code, the instruction pointer has to go back and forth. Initially, the pointer will start at the first character and move 3 steps at a time. For example: <code>1  1  +  O  @</code> will add 1 + 1 and output 2 before terminating.

If the pointer is about to step out of bounds, it reverses direction. You can use this to edit the previous program to the shorter 1O.1+@. The program evaluation goes like so:

1  1 →   Bounce off end and go left
←O  +←   Bounce off start and go right
→ .  @   Output and terminate

This can lead to some very compressed programs folding in on themselves, like "ol!,ld elWHro" printing Hello, World!.

But if you want to decrease the step count of the pointer, you can with v or W. The program W"!dlroW ,olleH"H first changes the step count to 1 and then prints Hello, World!. If you want to go the other way, you can use ^ or M to increase the pointer steps. Note that if you decrease the step count to negative then not only will the pointer move in the other direction, directionals like <> will have the opposite effect.

Data structure

Similar to Brain-Flak, Backhand uses two separate stacks. You usually operate on the main stack, but you can pull/push to the other stack with ( or ), or even switch stacks with x. Attempting to pop from an empty stack will yield a 0 instead.

Operators

GroupCharacter(s)NameAction
Literals
0-9a-fNumberPushs the appropriate hexadecimal number. The characters a to f push the values 10 to 15
"StringTurn on string mode, which pushes the ordinal value of each character it lands on until it reaches either another "
'CharacterPush the ordinal value of the next instruction instead of executing it
Stack manipulation
~PopPop and discard a
$SwapPop a then b and push a then b
:DupePop a then push a twice
&RegisterIf there is not a value in the register, pop a and store a in the register. Otherwise, push the value in the register and clear it
rReverseReverse the stack
lLengthPush the length of the stack
(PullPop a from the other stack and push a
)PushPop a and push a to the other stack
xSwitchSwap the main and other stack
Control Flow
<LeftChange direction to left
>RightChange direction to right
{Step LeftStep left one
}Step RightStep right one
^Increment StepIncrease the step value by 1
MDouble Increment StepIncrease the step value by 2
vDecrement StepDecrease the step value by 1
WDouble Decrement StepDecrease the step value by 2
?RandomStep left or right randomly
jJumpPop a and jump to the ath character, bouncing off the sides as usual. 0 represents the first character
sSkipPop a and skip forward a characters, bouncing off the sides as usual. This moves forward in the current direction
@TerminateEnd the program
Branching
_Decision StepPop a and if a is zero step right, else step left
|Decision ChangePop a and if a is not zero reverse direction
!NotPop a and push 1 if a is equal to 0, otherwise 0
LLessPop a then b and push 1 if a is less than b, otherwise 0
GGreaterPop a then b and push 1 if a is greater than b, otherwise 0
EEqualPop a then b and push 1 if a is equal to b, otherwise 0
Arithmetic
-SubtractionPop two values a then b and push b-a
+AdditionPop two values a then b and push b+a
*MultiplicationPop two values a then b and push b*a
/DivisionPop two values a then b and push b//a, the integer division of b and a
%ModuloPop two values a then b and push b%a, where the sign of the result matches the sign of a
[DecrementPop a and push a-1
]IncrementPop a and push a+1
Input/Output
iASCII inputPush the ordinal value of the next character in input. If there is no input left, push -1
oASCII outputPop a and output a as a character
INumber inputIgnore input data until it reaches a number and push that number. If the number is preceeded by a - then the number is negative. If there is no input left, push -1
ONumber outputPop a and print a as a number
\nNewlinePrint a newline
HHaltPrint the contents of the stack as a string and terminate the program
hFinishOutput the top of stack as a number and terminate the program

Any other character is ignored.

Example programs:

Countdown from 10

aO0{@|}}:
.O[.

Hello, World!

"ol!,ld elWHro"

Cat program

io

Truth Machine

I|@}: O

Count up forever:

]{O:.

Factorial:

1@ IO :~!{|{}: ([ *).

Quine:

"#v{<@^:[ba+0v|{$:o[}

Printing Backhand

"acdBkn"haH