I made a BF compiler that goes really fast. I'm in a compilers class right now and for whatever reason my professor has gotten severely nerd snipped into building the fastest BF compiler in the world.
Mine is pretty darn fast; it compiles to native ARM assembly and can generate a Mandelbrot set in less than 0.5 seconds on my M1 Pro machine. Full writeup (with links to source) here: https://lambdaland.org/posts/2024-10-22_bf_writeup/
A while ago I wrote a Zig brainfuck implementation[1] that converts Brainfuck code into an executable function at comptime. The performance is similar to transpiling the code to C and compiling it with full optimization settings.
Love the shoutout to Adam B. Dude has helped me so many times. He has a criminally under appreciated YouTube channel where he solves pretty complicated problems in real time at the REPL and talks his way thru and by the end of it you actually feel like you understand wtf just happened. At least until you go try it yourself.
Here's some function list usage: for V0 here, branching on each potential character is inefficient; so an option is to do an array index-of among the characters, and pick out the respective function from a function list: https://dzaima.github.io/paste/#0dZLPSgJRFMb38xQXNyajNRPUwqy... (and, for a duration of 1 glyph, there's even a matrix containing functions there!)
> APL is not only adjacent to math, but also emoji
Syntactically, mathematicians do tend to communicate via fair lengths of natural language interspersed with [greek with a smattering of hebrew, hiragana, etc.]; it hadn't occurred to me before now that the general population now also communicates with shorter lengths of natural language interspersed with emoji.
Do the generations which grew up with emoji have any less math phobia than mine did?
> fair lengths of natural language interspersed with [greek with a smattering of hebrew, hiragana, etc.]
Also some made up stuff also. For example in financial maths, the the derivative of an option's price with respect to volatility is called "vega". Why? Well because all the other option derivatives are named using Greek letters (delta, gamma, rho etc) and "vega" sounds sort of Greek even though it's just made up.[1]
The original BF implementation used a fixed-size memory of 30,000 cells and out-of-bound pointers weren't checked, making it highly unsafe. Most modern implementations support dynamically sized memory or at least bound checks though, so they are as safe as Rust.
I use a variant of BF for linear genetic programming experiments that wraps the memory pointer around when it hits the edges. This increases the chances of finding viable candidates by reducing the impact of bad mutations.
Mine is pretty darn fast; it compiles to native ARM assembly and can generate a Mandelbrot set in less than 0.5 seconds on my M1 Pro machine. Full writeup (with links to source) here: https://lambdaland.org/posts/2024-10-22_bf_writeup/