256

From Esolang
Jump to: navigation, search

256 is a Stack-based esoteric programming language made by Areallycoolusername. It was made for Code Golf, and it's a Turing tarpit.

Commands

256 has 4 commands. Each of these commands are integers, and they deal with input, output, loops, control flow, and the stack.

Commands Function
2 Reads input to the stack
5 Declares a variable
6 label for Goto
^ If statement

Specifics

On first glance, 256 looks highly imcomplete, and doesn't look viable for use in competitive golfing. However, this language has the few instructions it has to create new functions. Any character in the program that doesn't match one of these commands, or isn't an argument in one of these commands, is printed during execution. Commands and their arguments are separated by a semicolon.

2

The input commamd, 2, reads one character from the user, and pushes it to the top of the stack. This command doesn't need any parameters, in order to minimize program size. e.g: 2;

5

The variable command, 5, declares a variable. This command has 2 arguments. This first is the variable name, which can only be 1 byte in lenth, and can be any Unicode character. The variable name length being only 1 byte is arbitrary, and doesn't affect us Turing completeness of this language, as the name is just a shell. The thing that matters is The value. The second argument is the value, which can be an integer, string, character, or boolean. e.g: 5i99;

6

The label command, 6, is (arguably) the most essential command in this language. Without it, loops would not be allowed, and 256's use in competitive golfing would be nonexistent. In order to use this instruction, just put it anywhere in the program where you want to initiate a loop. Then, you can jump to it by calling 6 again, followed by what order that 6 is in. e.g:

6;h;61;6;e;62;

This program declares a 6. It is the first 6 in the program, so in order to jump to it, you have to declare 6 again, followed by a 1. This is done after the character "h" is printed. Another 6 is declared. It's the second 6 in the program, so in order to jump to it, a 6 has to be declared, followed by a 2. This is done after the character "e", is printed. However, the program will.never get past the first jump instruction, as the program has entered an infinite loop. So "h" is printed indefinitely.

^

The if statement, ^, is the fourth and last command in 256. When used, it must be followed by a condition, another ^ to tell the program what to do it the condition is met, and, optionally, another ^ to tell the program what to do otherwise. e.g:

5z99;6;^z>0^z;z--;61;^62;6

This program declares the variable z, with value 99. It then checks if a is more than 0. If it is, then z is printed, decremented, and the program jumps back to the start of the if statement. Otherwise, the program jumps to the second 6 I. The program, and halts.

Computational class

256 is Turing complete, as it can enter an infinite loop, and the stack is unbounded. Due to its use of only 4 commands, this language can also be considered a Turing tarpit.

Examples

Here are examples of popular problems in 256. Each example has the amount of bytes used in each program, in order to prove that 256 can still be used in competitive golfing.

Hello World Program

13 bytes in total.

Hello, world!

Truth Machine

18 bytes in total.

5i;2;^i=1^1^6;0;61

When a variable has the command 2 as it's value, it must be separated by a semicolon.

Infinite Loop

4 bytes in total.

6;61

Unofficial instructions

Due to 256's extreme simplicity, a program is very hard to golf in.

Integers instruction; i.e. the Looping counter (integers from top of stack down to 0), 25 28 bytes

5i12;6;i>0^i;i>0^5ii-1;2;61;

Call this instruction by typing ι; as an instruction.