Version française (différente) ici

The brainfuck is a basic and obfuscating language. It allows to manipulate pointers in the memory and change the pointed bytes. It was used for an implementation of the very famous TapTempo , but even if it Turing-complete, it needed piping to works under Linux.

I was bored during a long Pullman trip, and concerned about this problem. So I created the Advanced BrainFuck to solve it.

The advanced brainfuck (ABrainfuck) allows a great new feature: it can open files!

In unix-like system, it means you can manage stdin stdout but also any files read/write, which is great! you can do a lot of things, such as read the /dev/random to get random numbers, or /proc/driver/rtc to get a time!

The operators are mostly the same, just an important difference with ',' and '.': it does not access the stdin, but the current open file (by default stdout, so ',' does nothing).

to open a file ( /dev/stdin for instance), you can use the switch operator '~'. It will open the file with the address corresponding to the string starting at the current memory pointer position (which should be ended by \0 ).

Once open, you are in "file mode" the '.' operation copy from the file to the memory, and the ',' operation copy from the memory to the file. To switch back to "memory mode", reuse the '~' operator. In this case the operators are reversed, '.' copy from the memory to the file and ',' copy from the file to the memory.

Each time you read/write a file in memory mode, the file pointer is automatically shifted by +1.

Each you read/write the memory in file mode, the memory pointer is automatically shifted by +1.

If you are in file mode, the reading overwrite the memory where was the pointer, so the file address. If you switch back to memory, you can shift the memory pointer and still get data from the file with the operator ','. But to shift the file pointer by a custom value, you need to reopen it.

Bellow an application of the ABrainfuck for TapTempo (it was the main motivation in fact, so serious... commented code here ) Yes! TapTempo has reached an important milestone: it generated a dedicated technology!

But even if in first attention it was created for TapTempo, do not hesitate to use it for your own creations!

Have fun!

ABrainFuck.abf