I've recently rediscovered an interest in Befunge, the well-known two-dimensional esoteric programming language. Just to give you a flavour, in case you don't know the language, this program prints ‘Hello befunge’:
0"olleH">:#,_"egnufeb"v >,v 8 |:<*4< @
After submitting a Befunge implementation to Dave Plummer’s prime number calculating drag race, I thought I’d try my hand at writing my own interpreter for the language.
While there are some excellent interpreters out there (much better than what I’ve managed to write so far), I was particularly disappointed that there didn’t appear to be any good Befunge-98 interpreters that run in the browser.
My interpreter is written in Rust and inventively named rfunge (the rustiest of funges). You can get the sources on github, or you can try it directly in your browser.
That’s one of the charming things about Rust: it as unusually good support for deploying to WebAssembly.
I won’t say much more about my implementation here, suffice it to say that it has a fairly limited feature set, it’s quite a bit slower than other interpreters, but it may be the best Befunge-98 interpreter that runs in the browser right now.
A large part of the development process was, of course, testing the behaviour against other implementations. This meant installing a number of Befunge interpreters, and some of them are quite hard to get running. So here’s a brief guide on how to install some of the older interpreters on a modern Linux system (assuming you have a working C/C++ development environment with the usual selection of headers and libraries):
cfunge is probably the fastest and one of the easiest to get running. I didn’t have much luck with old releases, but the latest version from git works a charm.
git clone https://github.com/VorpalBlade/cfunge mkdir cfunge/build cd cfunge/build cmake .. make sudo make install
I only had one issue: some Linux systems (including mine) use a ‘reentrant’ build of ncurses, which cfunge does not support. These are easily disabled by running
cmake .. -DUSE_NCURSES=OFF
rcFunge may be the most full-featured befunge interpreter, and
the sources weren’t too hard to build. To build on Linux,
you have to edit the
Makefile, uncomment a few lines starting at line 26, and
comment out the OSX configuration starting on line 32. You will need development
headers for libX11 (install
libX11-devel or similar).
As rcFunge uses a plain Makefile with no configuration system, it’s possible that I was just lucky and you’ll have a harder time building.
rcFunge has crashed for me when running the Mycology test suite, so it’s possible some fingerprints don’t actually work on current systems.
CCBI is probably one of the best Befunge-98 interpreters (if a bit slower than cfunge), but simultaneously one of the hardest to install as it’s written in D version 1, which is effectively a dead programming language.
To build it, you’ll need a suitably old D compiler and the tango library. Luckily, tango provides a complete bundle, including a compiler, which, even though it’s 32 bit and a decade old, still works on a modern amd64 Linux system. CCBI then works flawlessly, albeit without ncurses support (at least for me).
Download the tango bundle to somewhere, grab CCBI from GitHub, and configure with
PATH=/path/to/tango-bundle/bin:$PATH \ CXXFLAGS=-m32 CFLAGS=-m32 LDFLAGS=-m32 \ cmake .. -DFINGERPRINT_TERM=off -DFINGERPRINT_NCRS=off
make install should work as expected.
FBBI, the Flaming Bovine Befunge-98 Interpreter, is widely acknowledged (at least by its author) to not be a great interpreter, but it’s easy to get working. Download the latest release, then
cd fbbi-1.0-2015.0729/src make
and an executable
fbbi should be placed in
Note FBBI does not support Concurrent Funge-98.
PyFunge isn't the easiest to find, as the original download link on the website is dead. However, the source is still available on PyPI and works with the latest Python 2.7. (Not Python 3, as you might imagine from its age).
PyFunge is pretty good, but its implementation of Concurrent Funge appears to be a bit buggy.
jsFunge-98 is the only other web-based Befunge-98 interpreter I’m aware of.
Sadly, it’s no longer publically hosted anywhere, and it’s less complete than
rfunge at this point. However, if you download it locally and open
in your browser, it does work.