Skip to content

Latest commit

 

History

History
50 lines (38 loc) · 1.9 KB

File metadata and controls

50 lines (38 loc) · 1.9 KB

Go Reference Go Build/Test CodeQL

GoBF

This is a BF interpreter and optimizing compiler written in Go.

GoBF can simply run your BF program or compile it to a binary to run later.

Obligatory Install Line

go install github.com/linux4life798/gobf@latest

Usage

The command-line program currently supports compile, gengo, run, and dumpil actions.

Give it a try!

go install github.com/linux4life798/gobf@latest

wget https://github.com/erikdubbelboer/brainfuck-jit/raw/master/mandelbrot.bf
gobf compile mandelbrot.bf
./mandelbrot

Note that the run command will simply interpret the BF program in-place, thus the performance will be as-is. Please use the compile to generate an optimized program.

Please see gobf --help for more fun options!

Optimization

The generated code optimizer reduces redundant and repetitive commands, like data pointer moves or incrementing a data cell. It coalesces multiple moves or data cell changes into one operation. Due to BF's repetitive nature, this typically increases the BF program's performance dramatically. All of the interesting optimization stuff is in the gobflib/il package.

Recent work has added some pattern-based and vectorization-based optimizations, but these have not been fully calibrated yet.

To try the zero pattern optimization, invoke gobf in the following manner:

gobf -O zero compile mandelbrot.bf