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.
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/
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!)
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.
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.
Give Adam some love (or at least likes!):
https://youtube.com/@abrudz
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/
I love APL. For a somewhat more modern, smaller take, try this: https://mlochbaum.github.io/BQN/
I was really impressed with BQN as a modern APL. Give it a look.
Love the idea of ndarrays of first class functions, although I'm still trying to figure out what I'd do with all that power...
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!)
Well ... consider my brain fucked
This is kind of funny. Implementing bf in something that is more-or-less just as brain-scrambling itself.
How does Brainfuck compare to Rust?
The syntax of BF is far simpler, so it should be easier to get started than rust.
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.