2 ms·
I once showed a colleague of mine how easy it is to compile brainfuck to C. He said that compiling to assembly was better and it would be easy to implement opti
by marcodiego 5y ago
I once showed a colleague of mine how easy it is to compile brainfuck to C. He said that compiling to assembly was better and it would be easy to implement optimizations. I told him he was underestimating GCC optimizations capabilities. He them implemented a brainfuck compiler to x86 asm and optimized any sequence of repeating ops and the zero cell ([-]) sequence. Turned out that "gcc -O2" was still significantly faster.
- stevekemp 5y agoI wrote a simple compiler for brainfuck too: https://github.com/skx/bfcc https://github.com/skx/bfcc Compiling to assembly language was pretty fast, but folding in repeated characters definitely made it faster still. Optimizing the assembly wasn't a particular goal, I guess recognizing loops that zero addresses, and similar, would be a good way to start.