Jump to content

Beatnik (programming language)

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Rezonansowy (talk | contribs) at 14:06, 23 March 2016 (Markup: expand with descriptions from https://esolangs.org/wiki/beatnik#Commands). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Beatnik
ParadigmStack-based
Designed byCliff L. Biffle
DeveloperCliff L. Biffle
First appeared2001; 24 years ago (2001)
OSCross-platform
Websitecliffle.com/esoterica/beatnik.html

Beatnik is a simple esoteric programming language, based on a stack. A beatnik program consists of any sequence of English words. Each word is assigned the score you would get for it in a Scrabble game. The value of the score determines what function is performed. Functions include pushing the score of the next word onto the stack, testing the stack and skipping forward or backward in the program and other stack operations.[1][2][3]

Overview

Markup

The interpreter reads the words in the poem, ignoring punctuation and whitespace and newlines. Some functions are one word, other functions have an argument (they are 'two-word functions'). Two-word functions are described below in the form "5,n". This means both the word whose value is 5 and the next word (whose value is 'n') are read.[1][2]

Commands
Word value Pseudo-code Description
<5 NOOP Optional: Interpreter may mock you
5,n push(n) Push the next word's value onto the stack.
6 pop() Pop a number from the stack and discard it.
7 push(pop()+pop()) Pop two numbers, add them, and push the result.
8 push(input()) Input a character and push its value.
9 print(pop()) Pop a number and output it as a character.
10 push(pop()-pop()) Pop two numbers, subtract the first one popped from the second one popped, and push the result.
11 a = pop(); b = pop(); push(a); push(b) Pop two numbers, swap them, and push them back.
12 a = pop(); push(a); push(a) Pop a number and push it twice.
13,n if(top()==0) jump(+n) Pop a number and skip ahead n (actually n+1) words if the number is zero.
14,n if(top()!=0) jump(+n) Pop a number and skip ahead n (actually n+1) words if the number isn't zero.
15,n if(top()==0) jump(-n) Pop a number and skip back n words if the number is zero.
16,n if(top()!=0) jump(-n) Pop a number and skip back n words if the number isn't zero.
17 exit() Stop the program.
18-23 NOOP Optional: may mock you, but only if it has had a bad day.
>23 Generates "Beatnik applause".
Legend
Pseudo-code Meaning
NOOP Do nothing
pop() remove the value off the top of the stack, and return it
push(x) place x on the stack
print(x) print the character x
input() read a character from the user. Blocks until character is read.
; separates multiple statements. They are run in order.
if(expression) statement if and only if the expression is true, execute the statement
jump(x) move the reading location forward or backwards by x words.

Here are the scrabble letter values, for reference.

Examples

Hello World

A "Hello World" example in 'Beatnik' language. Note: this actually prints "Hi" instead of "Hello, world".

   Baa, badassed areas!
   Jarheads' arses
         queasy nude adverbs!
       Dare address abase adder? *bares baser dadas* HA!
   Equalize, add bezique, bra emblaze.
     He (quezal), aeons liable.  Label lilac "bulla," ocean sauce!
   Ends, addends,
      duodena sounded amends.

See also

References

  1. ^ a b "Beatnik - Esolang". esolangs.org. Retrieved 2016-03-23.
  2. ^ a b Biffle, Cliff (19 May 2001). "Beatnik – cliffle.com".
  3. ^ Gruppe, Bcher (2010-07-01). Esoterische Programmiersprache: Intercal, Brainfuck, Befunge, Shakespeare Programming Language, Whitespace, Ook!, Beatnik, Piet, Malbolge, Chef (in German). General Books LLC. ISBN 9781158960996.