ARCANE PROGRAMMING LANGUAGES

Arcane Programming: Befunge

Justin Ohms
4 min readJun 18, 2023

If there ever was a language designed to befuddle a programmer and a compiler all while looking deceptively simple, Befunge is it.

Hello World in Befunge

The History of Befunge

I think it is a happy coincidence that Befunge sounds a lot like befuddle and yet that’s not the origin of the name. The name Befunge is derived from a typing error where the writer intended to write the word ‘before’.

Here again, we have a language conceived of and created in the early ’90s and once again on my favorite computer of the time, the Amiga. Like that other language from the early ’90s, Brainfuck, Befunge was designed to frustrate as much as it was to be a functional language. Unlike Brainfuck which was designed to be complicated for programmers, Befunge was created to be complicated for the machines that ran it. Its creator, Chris Pressey, invented this unique language with the aim of making it as complicated as possible to compile, a characteristic that gives Befunge its distinct identity.

While many other languages on this list are complex, Befunge takes it to a new level, with a design philosophy that subverts normal programming language design. Its creation was more of an intellectual sport rather than a practical undertaking.

Syntax and Architecture

In the world of Befunge, programmers are not bound by the linear, one-dimensional rule of reading and executing instructions. This language is two-dimensional, and the instructions are scattered across a grid. This adds an interesting spatial element to the programming process.

This is the first weirdness that a programmer encounters. Instructions in Befunge can be executed in four directions: left, right, up, and down. This is made possible because unlike “pointers” in other languages, “pointers” in Befunge don’t point to memory locations or variables but can be viewed as literal arrows that control the direction of code execution. In a bit of genius, the four pointers are all single-character symbols, “<” left, “>” right, “^” up, and “v” down. Two more operators control conditional flow “|” will conditionally branch either up or down, and “_” will move either left or right. One additional operator “?” will randomly pick a direction to follow. The result of all this is a layout that feels like navigating a maze, adding an unusual level of complexity that is not found in conventional languages. (Oh and absolutely necessitating the use of a monospaced font.)

Other than this oddness, Befunge is another stack-based language, where numbers are pushed onto a stack and the operations are performed on the stack. It has a minimalist design, which relies on just 20 commands. The real game-changer however is its ability to modify its own source code during execution (a feature known as ‘reflectivity’), with this Befunge becomes a dynamic puzzle of programming.

For a programmer well-acquainted with conventional languages, writing the first program in Befunge feels like stepping into an alternate reality. It seems more like solving a sudoku than writing code.

For compilers this ability to execute code in multiple directions, and the ability to alter the code while executing makes writing a compiler exceedingly difficult if not impossible. Still, there have been several attempts most using some sort of just-in-time compilation strategy.

The Future of Befunge

I’ve had a bit of fun playing around with Befunge. But like all of these esoteric languages, it is certainly not suited for everyday coding tasks or commercial software development.

What makes Befunge really compelling is that it promotes a different kind of thinking. It challenges the mind and cultivates a new form of understanding about code execution and control flow. The unique nature of this language can enhance creative problem-solving skills, providing a much-needed break from the standard conventions of programming.

The original version of the Befunge-93 specification and interpreter as written by Pressy for the Amiga is not Turing complete because the instruction space (program size) is limited to a grid of 80x25. Later updates such as Funge-98 remove this limitation and are Turing complete. With these updates, Befunge and its descendants have a long future for those dedicated to the world of esoteric languages.

This article is just part of an ongoing series on Arcane and Esoteric programming languages. Follow me if you want to see more.

I write on a wide variety of topics including programming, travel, politics, books, and AI. You can see all of my stories on Medium here.

If you like my stories on Medium, you can subscribe here to get them directly in your inbox. That way you’ll never miss one!

You can also support other authors and me by joining the Medium community. Sign up for a membership using this link. For only $5 a month, you get unlimited access to all the stories on Medium and I also get a small commission at no extra cost to you.

(Some of the links in my articles may be affiliate links for which I might receive a small commission.)

--

--