2016-06-20 Brainfuck compilers implemented and results compared

After implementing a "Brainfuck to COBOL"-compiler (read the story here, TL;DR: I work at a company where they do automated conversions of programming languages) I became inspired to implement other compilers as well.

Below you will find other compilers and how well the resulting code performs.
For each I tested the run-time of the brainfuck mandelbrot implementation. Where possible I used the "-flto -O3 -march=native -fomit-frame-pointer" compiler flags.
The compilers to do these compilations/conversions are in this tar file or on GitHub.

languagerun time (HH:MM:SS.hh)remarks
6502 asm (C64) Vice 3.0.0.dfsg-2
Ada00:00:02.65GNAT 6.1.1
ArduinoNano328: 00:18:14.89
ESP8266: 00:02:55.97
Nano328 with Arduino 1.0.5 environment
ESP8266-F with Arduino 1.6.6 environment
ARM asmRPI 1b: 00:00:26.98
RPI 2: 00:00:11.74
RPI 3: 00:00:07.54s
RPI = Raspberry Pi
C00:00:01.61GCC 5.3.1-14
C#00:00:04.32Mono C#
Cobolcobc: 00:02:54.37
cobc+gcc: 00:02:50.48
OpenCOBOL 1.1.0
GCC 5.3.1-14
Go00:00:03.58Go 1.6
Java00:00:10.66java version "1.7.0_65"
OpenJDK Runtime Environment (IcedTea 2.5.2) (7u65-2.5.2-2)
OpenJDK 64-Bit Server VM (build 24.65-b04, mixed mode)
Javascript (nodejs)00:00:06.24nodejs 4.2.1~dfsg-1
Lualua: 00:03:07.18
luajit: 00:00:09.04
Lua 5.2.3
Lua jit 2.0.4
Pascal00:00:03.73fpc 3.0.0+dfsg-6
compiler switch: -O4
Perl 500:02:16.39perl 5.22.1
Perl 600:42:48.152016.05
PHP00:01:22.60PHP 5.6.16-2 (cli)
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies
PL/100:04:32.780.9.9a (Iron Spring compiler)
Pythonnuitka: 00:02:11
python 2: 00:02:58.05
python 3: 00:03:11.86
pypy: 00:00:08.12
pyston: 00:01:59.84
shedskin: 00:00:01.95
nuitka 0.5.25
python 2.7.9
python 3.4.2
pypy 5.3+dfsg-2
pyston 0.5.0
shedskin 0.9.4-1 (with -borsw switches)
Ruby00:01:41.96ruby 2.1.2p95 (2014-05-08)
Rust00:00:01.30rust 1.14.0+dfsg1-3
Scala00:00:51.46Scala code runner 2.11.8
SDL Basic00:22:
x86 asm00:00:01.48x86 assembler, at&t syntax
Z80 asm (MSX)06:48:50OpenMSX 0.13.0-1+b1


  • 2016-06-16: made sure data values stay 8 bit unsigned. This affects run-times in some occassions.
  • 2016-06-18: brainfuck-compiler.tgz is the rewritten code which contains all language targets in one program.
  • 2016-06-20: ironically the brainfuck to cobol compiler was broken. that is now fixed.
  • 2016-06-25: added Lua and Arduino. Note that the Arduino target uses a memory size of 1536 bytes while a Brainfuck interpreter usually has at least 32000 bytes. The mandelbrot works fine on a Nano328. Other Arduinos may have bigger memory (Arduino Mega?).
  • 2016-06-25: added ESP8266 for Arduino environment
  • 2016-06-26: added Bash and SDL Basic
  • 2016-07-11: implemented Perl 6 suggestions by Brad Gilbert which made the resulting code 19x faster!
  • 2016-07-14: x86 assembly code
  • 2017-02-09: PL/1 target
  • 2017-05-29: Scala target
  • 2017-06-10: ARM (assembly) target
  • 2017-06-28: Commodore 64 (assembly) target, MSX target bugfixing (is now able to run the mandelbrot benchmark)
  • 2018-01-13: Rust target