Optimizing Brainfuck interpreter in the C preprocessor
Published on: 2025-06-01 10:34:07
Optimizing Brainfuck interpreter in the C preprocessor
A C99 confirming* optimizing Brainfuck implementation written (and executed) only using the C preprocessor.
*If you find something that does not confirm to the standard or is unspecified/undefined, please open an issue.
Example
Hello World Output #include "bf.c" BF (, I , I , I , I , I , I , I , I , B , R , I , I , I , I , B , R , I , I , R , I , I , I , R , I , I , I , R , I , L , L , L , L , D , E , R , I , R , I , R , D , R , R , I , B , L , E , L , D , E , R , R , A , R , D , D , D , A , I , I , I , I , I , I , I , A , A , I , I , I , A , R , R , A , L , D , A , L , A , I , I , I , A , D , D , D , D , D , D , A , D , D , D , D , D , D , D , D , A , R , R , I , A , R , I , I , A ) "Hello\x20World!
"
Multiplication (0xc*0xa) Output (0xc*0xa=0x78) #include "bf.c" BF (( c , a ), G , R , G , L , B , R , B , D , R , I , R , I , L , L , E , R , R , B , D , L , L , I , R , R , E , L , L , L , D , E , R , R , O ) "(78)"
Check out
... Read full article.