HNHacker News
TopNewBestAskShowJobs

john-h-k

384 karma · joined March 23, 2025

https://johnk.dev
submissionscomments
john-h-k··on Optimizing Brainfuck interpreter in the C preprocessor
Yes. The biggest win (that you may already do) is recording branch positions, so when you hit a `[` or `]` knowing exactly where to jump through rather than going left/right. My interpreter above isn't the most advanced (it was a few hours while hungover because it seemed fun!), but try throwing it at your thing and I suspect it could help.

``` cargo install --git https://github.com/john-h-k/rustfuck

rustfuck <source> --lir # or --jit if you are on arm64 and don't need to read from stdin ```

john-h-k··on Optimizing Brainfuck interpreter in the C preprocessor
Optimising the program absolutely will win in general, because the optimisations are extremely cheap and very impactful. See https://github.com/john-h-k/rustfuck for an example of the sort of speedup differences you can get with different optimisation levels
← PreviousPage 7 of 7