256

From Esolang
Jump to navigation Jump to search
256
Paradigm(s) Turing tarpit
Designed by Areallycoolusername
Appeared in 2019
Memory system Stack-based
Dimensions One-dimensional
Computational class Possibly Turing complete
Major implementations 256.js
File extension(s) .256
Not to be confused with Py256.

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. Most 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 incomplete 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. However, if the character is also the name of a variable then that variable's value is printed instead.

Commands and their arguments are separated by semicolons.

2

The input command, 2, reads one character from the user, and pushes it to the top of the stack (the last defined variable). 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 length, 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. The second argument is also optional (mostly so it can be set by the input command, #2). e.g:

5i99;

This sets the variable is value to 99.

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 in the program, and halts.

Computational class

256 is possibly Turing complete, as it can enter an infinite loop, and the stack is unbounded. Due to its use of only 4 commands, this language would also be considered a Turing tarpit if so. However, no Turing complete language has yet been simulated in it.

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

0 to 100

Prints numbers from 0 to 100. 29 bytes in total.

5z0;6;^z<101^z; ;z++;61;^62;6

Unofficial instructions

256's extreme simplicity makes it difficult to code 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.

Interpreters

256.js

256.js is a 256 interpreter in NodeJS made by Duckologist.