Implementing Brainfuck in APL

(blog.wilsonb.com)

33 points | by pabs3 4 days ago ago

11 comments

  • upghost 4 hours ago

    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

  • ashton314 2 hours ago

    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/

  • anyfoo 5 hours ago

    I love APL. For a somewhat more modern, smaller take, try this: https://mlochbaum.github.io/BQN/

    • BoiledCabbage 5 hours ago

      I was really impressed with BQN as a modern APL. Give it a look.

      • upghost 4 hours ago

        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...

        • dzaima 3 hours ago

          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!)

  • cosignal 5 hours ago

    Well ... consider my brain fucked

  • seanhunter 4 days ago

    This is kind of funny. Implementing bf in something that is more-or-less just as brain-scrambling itself.

  • nullorempty 2 hours ago

    How does Brainfuck compare to Rust?

    • askl 7 minutes ago

      The syntax of BF is far simpler, so it should be easier to get started than rust.

    • lifthrasiir an hour ago

      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.