A collection of BF interpreters in different languages. GPLv2 or later license.
Implementing BF is a great way of exploring unfamiliar programming languages. There's non-trivial logic, some I/O, and multiple data types. BF is still small enough that you can build a complete implementation in an evening or two.
For a robust, high performance BF implementation with good user feedback, see my 'industrial-grade' BF compiler.
Table of Contents
Apache Maven required.
$ cd java/brainfrack $ mvn package
The Java implementation reads programs from standard in.
$ cat ../../sample_programs/hello_world.bf | java -cp target/brainfrack-0.1.jar com.github.wilfred.App Hello world!
The Haskell implementation reads programs from standard in.
$ cd haskell $ ghc Brainfrack.hs $ cat ../sample_programs/hello_world.bf | ./Brainfrack
The Clojure implementation reads programs from standard in.
$ cd clojure/brainfrack $ lein compile $ cat ../../sample_programs/hello_world.bf | lein trampoline run
The C implementation reads programs from standard in.
$ cd c $ make $ cat ../sample_programs/hello_world.bf | ./brainfrack
$ cd racket $ cat ../sample_programs/hello_world.bf | racket brainfrack.rkt
http://www.hevanet.com/cristofd/brainfuck/tests.b is a treasure trove of implementation tests. Most implementations here don't pass all these tests yet.