Beatnik

From Esolang
Jump to: navigation, search

Beatnik is a stack-based esoteric programming language created by Cliff L. Biffle. The code looks like English-language text (typically with sentences that don't make a lot of sense). The words are scored according to the rules of the Scrabble board game, and the score is used to determine the operation.

Commands[edit]

5 Push the next word's value onto the stack.
6 Pop a number from the stack and discard it.
7 Pop two numbers, add them, and push the result.
8 Input a character and push its value.
9 Pop a number and output it as a character.
10 Pop two numbers, subtract the first one popped from the second one popped, and push the result.
11 Pop two numbers, swap them, and push them back.
12 Pop a number and push it twice.
13 Pop a number and skip ahead n (actually n+1) words if the number is zero.
14 Pop a number and skip ahead n (actually n+1) words if the number isn't zero.
15 Pop a number and skip back n words if the number is zero.
16 Pop a number and skip back n words if the number isn't zero.
17 Stop the program.

Any other Scrabble value, interpreted as a command, is a no-op. Note that the commands corresponding to values 5, 13, 14, 15, and 16 each read an extra word and use it as a parameter (then skip it). A value of less than 5 might make the interpreter mock you for your poor Scrabble skills. A value greater than 23 will earn you "Beatnik applause".

Computational class[edit]

Since there is only a single stack for data items, and since data items are finite (integers from 0 to 255), and since it is not possible to access values from arbitrarily deep in the stack, Beatnik is not Turing-complete, but it ought to be able to simulate any deterministic Push-down automaton.

Implementability[edit]

The author claims there is an error in the published specification and example program, but does not divulge where this error is. This means the Beatnik language is effectively ill-defined -- the error could be, for example, that the language exists at all -- and effectively unimplementable. Chris Pressey proposes using (when it is not clear from context) the term Beatnik at face value to refer to the language where the specification, as published, is considered correct (and the published example programs are considered incorrect.)

Example programs[edit]

These are given in Beatnik at face value.

Rudimentary example[edit]

Hello, aunts! Around, around, swim!

Input a character, take its ASCII value, add 7 to it, and output the corresponding ASCII character. For example, if the input character is A, the output character will be H.

Hello, world[edit]

See Hello world program in esoteric languages#Beatnik

Alphabet program[edit]

Ho humbuzz, Dionysus. | orgasm if I feel altruistic & alone...

Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch?! Ha!

Monarchies spoil; language intermediates everyone!

This program iterates from 32 to 127 (open on the right) and prints the character at that index. Thus, it displays the "printable" subset of the ASCII table, from 0x20 (space) to 0x7E (~).

Infinite loop[edit]

The simplest construction of an infinite loop in Beatnik (at face value) involves pushing any value (the positivity of which is guaranteed by the language's semantics) and then jumping backward four instructions. The following whimsical example is humorously self-referential:

Ha, an interminable line!

Truth machine[edit]

Truth beyond frontiers remains, but amazingly, falsities stay constant, existing greater.

This program implements a Truth-machine. If the character inputted is 0, it outputs 0 and terminates, but if the character inputted is 1, it outputs 1 infinitely (warning: this behavior will crash some interpreters).

Scrabble letter values[edit]

--- ABCDEFGHIJKLMNOPQRSTUVWXYZ ---
 1: A   E   I  L NO  RSTU
 2:    D  G
 3:  BC         M  P
 4:      F H             VW Y
 5:           K
 6:
 7:
 8:          J             X
 9:
10:                 Q        Z
--- ABCDEFGHIJKLMNOPQRSTUVWXYZ ---

External resources[edit]