5 ms·
An Optimising BF Compiler
- bdash 11y agoNeat! One of the projects that I wrote when learning Rust was a BrainFuck interpreter and JIT for x86_64[1]. Interestingly, my JIT appears to be run some programs (e.g., mandelbrot.bf[2]) significantly faster than the versions compiled by bfc. That's despite including the optimization and code generation overhead in the timings of my JIT, but excluding them from bfc. [1]: https://github.com/bdash/brainrust https://github.com/bdash/brainrust [2]: https://github.com/bdash/brainrust/blob/master/examples/mandelbrot.bf https://github.com/bdash/brainrust/blob/master/examples/mand...
- azeirah 11y agoAwesome! Inspired by a flash of lightning, I wrote a genetic algorithm to generate brainfuck over the past two weeks. It has gotten so far that it generates brainfuck programs that output any number you desire. No input processing though ;( Here are five different (20-char) brainfuck programs that print 1337.. Note my brainfuck interpreter doesn't output characters, it adds the byte at the current pointer to the output. I suppose that's not real brainfuck... -.[.>++<+.>]-.><+.[+ ++->]-.[+.-.-<++]--> -[...<[+].++>-.>+]<+ [+++...+.[-[.->.[]][ >->-[..<.->-.<<.+.]+ Now I want to either rewrite it in c (it's currently in js) for the performance increase alone. I might attempt writing an interpreter on my fpga...
- vanderZwan 11y agoHave you seen this work? http://www.primaryobjects.com/CMS/Article163 http://www.primaryobjects.com/CMS/Article163
- azeirah 11y agoYep, I have. Pretty cool stuff