Bitter

From Esolang
Jump to navigation Jump to search

Like Brainfuck - only much, much, worse.
The blame rests solely with User:DMC.

  • another brainfuck variation that uses 1-bit memory cells
  • four commands < > ( )
  • two interpreter commands  ! # used for debuging purposes, do not have to implemented, although it would probably help.
  • Influenced by: Brainfuck, Smallfuck

The Virtual machine

  • an array of one bit cells starting at zero
  • infinite and unbounded in the positive direction
  • all memory initialized to 0
  • for practical purposes, memory only needs to be large enough to accommodate a particular program
  • setting p to < 0 is an error and should halt the program
  • [p] bit value at memory location p
  • input: defined in initial program state
  • output: determined by examining memory
  • Mathematically equivalent to smallfuck if certain memory usage procedures are followed

Commands

Command Description
>
increment data pointer and invert bit
<
decrement data pointer and invert bit
(
if [p] == 1, proceed to next command, otherwise advance to command after matching ')'
)
go back to matching (
!
interpreter command: dump memory from 0 to highest value of data pointer
#
interpreter command: pause program and dump memory

Initialization process

  • Non-destructively initialize each bit in succession using: > or >><.
  • If the next bit is already what you want, use >><.
  • If the next bit is not what you want, > will invert it.

Examples

Hello, World!\n

Load memory 0 through 111 with 'Hello, World!\n'
>>><>>>><>>><>>>>><>>>><>><>>>>><>><>><>>><>>>>><>
><>><>>><>>>>><>><>><>><>><>>><>><>>>>><>>><>>>><>
>><>>><>>>><>><>>>>>><>><>><>>>>>>><>><>><>><>>><>
><>>><>><>><>>>>><>>><>><>><>>><>><>>><>>><>><>>><
>>><>><>>><>>><>><>>>><!

Truth Machine

initialize cell0 = zero

>><

end on cell1 = 0

initialize cell0 = 1

><(>><)

fill all memory with 1 ! dump memory after each loop

Tedious memory initialization process for 'Hello World'

0100 1000
> >>< > > >>< > > ><
0110 0101
> > > >>< > > >>< >><
0110 1100
> > > >>< >>< >>< > >><
0110 1100
> > > >>< >>< >>< > >><
0110 1111
> > > >>< >>< >>< >>< >><
0010 1100
> >>< > >< > > > >>< >
0010 0000
>>< > > >>< > >>< > >><>
0101 0111
> >>< > >< > > > >
0110 1111
>>< >>< >>< > > > > >
0111 0010
>>< >>< >>< >>< > >>< >>< >
0110 1100
>>< >>< >>< > > > >>< >
0110 0100
>>< >>< >>< > >>< >>< > >><
0010 0001
> >>< >>< > >>< > >>< >>
0000 1010
> >>< > >>< >>< > > >><

Computational class

A hypothetical version of Smallfuck with unbounded memory can be converted into Bitter directly as follows:

  • > becomes >><>
  • < becomes <<><
  • * becomes ><
  • ( becomes [
  • ) becomes ]

The basic idea is to use only every second cell on the tape to store data, with the cells between used as "bit buckets" to discard unwanted inversions, maintaining the parity of the tape. This makes the tedious initialisation process mentioned above unnecessary. It also shows the language to be Turing complete.

Orthodox Bitter

Using the 'bit bucket' method would probably make Bitter slightly easier to use. But if one was going to do that, they should probably use Smallfuck. That will be dificult enough.

Therefore, 'Orthodox' Bitter avoids using every other cell as a bit bucket.

External resources

  • Bitter – Interpreter in Python 3

See also

Other languages operating on bits (implemented only):