Talk:Bub
From Esolang
[edit] Spec Talk
The following is a direct quote from the Bub page in the Muriel archive:
Essentially, Bub is Brainf*ck using GOTOs instead of 'while' loops. A Bub program consists of a string of digits, and these are split into blocks of 'w' digits (w=4 in the Hello World program). In most instructions, all but the last digit can be ignored - the last digit corresponds to a Brainf*ck instruction, with 012345678 corresponding to <>+-,.[] and 'end of program' respectively. In the case of [ and ], the preceding digits signify the instruction number to jump to (counting from 0) if the jump takes place - in other words, when translating from Brainf*ck to Bub, the location of the corresponding bracket is calculated in advance.
For example, the program [-] could be translated as
0036 9993 0017 9998
The Muriel interpreter for Bub is the original Bub implementation. It verifies the following observations about the above "spec":
- Instructions ending in "6" and "7" are "jump if zero" and "jump if nonzero", respectively.
- A jump from a "6" instruction could jump directly to its corresponding "7" instruction or to the immediate instruction after the corresponding "7" instruction (since it is known that the "7" instruction will not branch). Likewise for "7" jumps.
- In fact, jumps of either style can point to any instruction either before or after the jump origination. They do not have to be paired with another jump.
- Thus, Bub is a more powerful language than brainfuck (at the expense of increased syntax). While brainfuck can be translated one-for-one into Bub, the reverse is not necessarily so.
--Nthern 16:17, 14 August 2007 (UTC)

