The Facefuck Programming Language is another esoteric programming language, which is heavily influenced by Brainfuck. Because the syntax of Brainfuck programs is very hard to grasp, Facefuck provides a different set of commands, better suited for the human reception. However, most of the features of Brainfuck, especially its Turing-completeness, remain with Facefuck.
The following describes the mapping of the Facefuck commands to their Brainfuck equivalents, and also their meaning. Facefuck exists for two different locales, to make its understanding even easier based on regional fashion.
|Brainfuck||Facefuck (en_US)||Facefuck (ja_JP)||Meaning|
|>||:>||>_>||increment the pointer|
|<||:<||<_<||decrement the pointer|
|+||:)||^^||increment the current data cell|
|-||:(||;_;||decrement the current data cell|
|.||:P||@_@||output the value of the cell at the pointer|
|,||:D||^_^||input one cell and store it at the pointer|
|[||=(||0_o||loop start: jump forward to the command after the corresponding end command if the cell at the pointer contains 0|
|]||=)||o_0||loop end: jump back to the command after the corresponding start command|
|n/a||/o\||throw an exception with the current cell's value (the interpreter might throw one when too many frowning faces occur in the code)|
Facefuck commands should be separated by whitespace to improve readability. Thus, depending on the locale, Facefuck code size is increased by 200-300% compared to Brainfuck. It is possible to compress same-command sequences in the en_US locale by repeating the second glyph accordingly. Example: :) :) :) :P can also be expressed as :))) :P. However, this syntax is not recommended because it is harder to read.
The following Facefuck code prints a "Hello World!" line to the screen:
:) :) :) :) :) :) :) :) :) :) =( :> :) :) :) :) :) :) :) :> :) :) :) :) :) :) :) :) :) :) :> :) :) :) :> :) :< :< :< :< :( =) :> :) :) :P :> :) :P :) :) :) :) :) :) :) :P :P :) :) :) :P :> :) :) :P :< :< :) :) :) :) :) :) :) :) :) :) :) :) :) :) :) :P :> :P :) :) :) :P :( :( :( :( :( :( :P :( :( :( :( :( :( :( :( :P :> :) :P :> :P
Here is an example for the typical "cat" program, replicating its input to the screen:
:D :) =( :( :P :D :) =)
brain2face.sed (jp) to convert Brainfuck code to Facefuck.
face2brain.sed to convert Facefuck code to Brainfuck.
faceFuck2D.d Facefuck code/executable generator using D's compile-time function evaluation (CTFE).
The language has been inspired by users of channel #D on freenode, where excessive usage of template mixins (a feature of the D Programming Language) made the code look like smileys. First proposed as an extension or run-time library for the D language and named "libsmiley", it was later changed to completely represent the command set of an already existing minimalistic language.
The name of the language (originally suggested as "smileycode" or "headfuck") has been chosen to represent the facts that it is a smiley faces representation of brainfuck, thanks to Zuu for this.
There are still many syntax elements open for usage, to be integrated into a language more powerful than brainfuck. For example, the \o/ operator could be integrated to catch exceptions, however it is not clear where to place it in the code flow.
If you have suggestions or improvement ideas, feel free to send them to the below mentioned e-mail address or to announce them on #D, so they can be integrated here.
© 2008-08-21 by Georg Lukas <firstname.lastname@example.org>