Beebles
Beebles is an esoteric programming language that is run in an interpreter named Beebles. Beebles is different from most interpreters in that it can quit without warning. It is a stack-oriented language where operations are performed on 2 stacks. It currently has 12 commands used to manipulate stacks and interact with the user, plus 1 command used to do exactly nothing (the nop
command).
Commands and Syntax
There are 13 commands, 12 of which are actually useful. Every command is formatted like this:
[name] [argument];
where name
is the name of the command, and argument
is the argument. Not all commands accept arguments.
All commands end in a semicolon, as shown by the example above. The command is separated from the argument by whitespace. These are the 13 commands:
Command | Description |
---|---|
push number |
Push number onto the current stack |
pop |
Pop the top item of the current stack |
outc |
Output the value of the top of the current stack as an ASCII character |
outi |
Output the value of the top of the current stack as an integer |
getc |
Get input from the user as an ASCII character, and push it onto the current stack |
goto number |
Jump to label with identifier number if the top of the current stack is not 0 |
label number |
Create a label with identifier number |
kill |
Kill the program |
add number |
Add number to the top of the current stack, and push the result onto the current stack |
flip |
Switch between stacks |
kick |
Move the top item from the current stack to the other one |
rem text |
Comment out text |
nop |
Do nothing |
The Beebles interpreter
The Beebles interpreter, named Beebles, really hates its job, so it's important that the programmer be cautious while writing code. If angered enough, Beebles may abruptly quit, leaving only an error message:
Beebles interpreter: Beebles got angry and crashed the program.
This error can be caused in many different ways. For example:
- Beebles likes when code is neatly commented; if there are no comments present, there is a higher chance that Beebles will get angry and quit.
- Beebles wants nicely formatted code - if there are 2 commands on a single line, Beebles gets angry.
- Beebles does not like memorizing all the numbers on the stack - if there are more than 30 numbers pushed on the stack, Beebles will get angry.
- Beebles hates profanity. If you swear in your code, Beebles has a very high chance of quitting.
- Beebles doesn't like when the
nop
command is used, because it just wastes time.
There are ways to make Beebles happy, however. These include the following:
- Beebles loves math. If you push a prime number to the stack, Beebles will get happier.
- If you format your code nicely (e.g., one command per line) Beebles will get happier.
- Beebles loves when you use loops, because it is a compact way of conditionally executing the same code over and over again.
- Beebles likes it when you compliment him, so it is best practise to write 'I love Beebles' in a comment somewhere in the program.
Note that since Beebles hates its job, it is quite grumpy even when the program starts. It is imperative that Beebles is appeased before any meaningful code is written.
Note on the 'add' command
Since the only actual data type is an 8-bit unsigned integer, the highest number that can be obtained is 255. That means that if two numbers are added with a sum of more than 255, the number will wrap around zero.
Example code
Hello World
rem ////////////////////////////////////; rem // helloWorld.beebles //; rem // July 29, 2012 //; rem // Prints "Hello, World!" //; rem ////////////////////////////////////; rem // I love Beebles. //; flip; push 0; push 2; push 3; push 5; push 7; push 11; push 13; push 17; flip; rem // Push numbers onto the stack //; push 0; push 10; push 33; push 100; push 108; push 114; push 111; push 87; push 32; push 44; push 111; push 108; push 108; push 101; push 72; rem // Print the stuff from the stack //; label 0; outc; pop; goto 0; pop; flip; label 1; outc; pop; goto 1; pop;
99 bottles of beer
This is a good example of the limitations of the Beebles interpreter; if the comments were removed, the program would quit after displaying the first number. Like many similar programming languages, it is easier to just write the lyrics to the song in Notepad.
rem /////////////////////////////////////; rem // bottlesOfBeer.beebles //; rem // July 29, 2012 //; rem // Prints the Bottles of Beer song //; rem /////////////////////////////////////; rem // I love Beebles. //; push 99; push 10; outc; pop; label 0; rem // Pushes stuff onto the stack //; outi; push 0; push 114; push 101; push 101; push 98; push 32; push 102; push 111; push 32; push 115; push 101; push 108; push 116; push 116; push 111; push 98; push 32; rem // Prints the pushed values //; label 15; outc; pop; goto 15; pop; push 0; push 32; push 44; push 108; push 108; push 97; push 119; push 32; push 101; push 104; push 116; push 32; push 110; push 111; push 32; rem // Prints the pushed values as chars //; label 1; outc; pop; goto 1; pop; outi; rem // Pushes "x bottles of beer" //; push 0; push 10; push 46; push 114; push 101; push 101; push 98; push 32; push 102; push 111; push 32; push 115; push 101; push 108; push 116; push 116; push 111; push 98; push 32; rem // Prints, "x bottles of beer" //; label 2; outc; pop; goto 2; pop; rem // Pushes "Take 1 down, pass it around" //; push 0; push 32; push 44; push 110; push 119; push 111; push 100; push 32; push 101; push 110; push 111; push 32; push 101; push 107; push 97; push 84; rem // Prints the pushed variables as chars //; label 16; outc; pop; goto 16; pop; push 0; push 10; push 100; push 110; push 117; push 111; push 114; push 97; push 32; push 116; push 105; push 32; push 115; push 115; push 97; push 112; rem // Prints "Take 1 down, pass it around" //; label 3; outc; pop; goto 3; pop; rem // Subtracts 1 from the number, display and kick to the other stack //; add 255; outi; kick; rem // Pushes "x bottles of beer on the wall" //; push 0; push 114; push 101; push 101; push 98; push 32; push 102; push 111; push 32; push 115; push 101; push 108; push 116; push 116; push 111; push 98; push 32; rem // Prints the pushed variables as chars //; label 14; outc; pop; goto 14; pop; push 0; push 10; push 10; push 32; push 46; push 108; push 108; push 97; push 119; push 32; push 101; push 104; push 116; push 32; push 110; push 111; push 32; rem // Prints "x bottles of beer on the wall" //; label 4; outc; pop; goto 4; pop; pop; rem // Flip to next stack //; flip; goto 0; push 0; push 98; push 32; push 102; push 111; push 32; push 115; push 101; push 108; push 116; push 116; push 111; push 98; push 32; push 101; push 114; push 111; push 109; push 32; push 111; push 78; rem // Displays the last verse, part 5 //; label 9; outc; pop; goto 9; pop; push 0; push 98; push 32; push 101; push 114; push 111; push 109; push 32; push 111; push 110; push 32; push 44; push 108; push 108; push 97; push 119; push 32; push 101; push 104; push 116; push 32; push 110; push 111; push 32; push 114; push 101; push 101; rem // Displays the last verse, part 4 //; label 8; outc; pop; goto 8; pop; push 0; push 114; push 111; push 116; push 115; push 32; push 101; push 104; push 116; push 32; push 111; push 116; push 32; push 111; push 71; push 10; push 46; push 114; push 101; push 101; push 98; push 32; push 102; push 111; push 32; push 115; push 101; push 108; push 116; push 116; push 111; rem // Displays the last verse, part 3 //; label 7; outc; pop; goto 7; pop; push 0; push 115; push 101; push 108; push 116; push 116; push 111; push 98; push 32; push 57; push 57; push 10; push 101; push 114; push 111; push 109; push 32; push 101; push 109; push 111; push 115; push 32; push 121; push 117; push 98; push 32; push 100; push 110; push 97; push 32; push 101; rem // Displays the last verse, part 2 //; label 6; outc; pop; goto 6; pop; rem // Pushes the last verse of the song. //; push 0; push 10; push 10; push 46; push 108; push 108; push 97; push 119; push 32; push 101; push 104; push 116; push 32; push 110; push 111; push 32; push 114; push 101; push 101; push 98; push 32; push 102; push 111; push 32; rem // Displays the last verse, part 1 //; label 5; outc; pop; goto 5; pop;
Interpreter
An interpreter is available here. It only accepts UTF-8 encoded text files with the .beebles extension. Also it only works on Mac. Windows users can make their own implementation.
Computational class
Because it has two stacks and the appropriate commands to manipulate them, Beebles is likely to be Turing-complete. However, pushing more than 30 numbers on the stack would make Beebles angry, which classifies the interpreter as a bounded-storage machine.