Befunge and Flobnar

A week-ish ago I discovered Flobnar, an esoteric programming language invented by Chris Pressey circa 2011 and described either as “a functional dual of Befunge-93” or “what happens when you get Befunge-93 drunk.”

Within a couple of hours, I had hacked together a Flobnar interpreter in C++; you can find it on my GitHub. Chris Pressey’s reference implementation is written in Haskell; there’s another version in Rust which is used by tio.run.

This is what a (non-conforming) “99 bottles of beer” program looks like in Flobnar:

99 bottles of beer on the wall
99 bottles of beer
Take one down, pass it around
98 bottles of beer on the wall

   5:
  >* <            <
  ^2$         v < ^
  ^:g,<         +< <<\<\ <
  ^$0 +<<<<<<\ \< ^  $^#
  ^` |<   :$$< v  ,  :^7
  ^: >\\^ %<   v  +  >^*v/<\@
  ^   #$ v< 1  v  >\  #4  ^#
  ^   1: v6+p< v  ## ^ \ < 9
  ^   +  v*<0+<v  ^: ^ #>v *
  ^   $  v8+p< v  ^- ^ 4 v #
  ^   :  v: 0 0v  ^1 ^ * v 9
 :^<<<<<<</<<<|<  ^  ^ 4 v +
 g,<     ^<   1   ^  ^   v 2
:2 +<<<<<<<<<<<<<< << <\<v
` |<             :^  ^ 0 v
#:>\^            `|     /<
7+ <             1  7^\\<:
*1                0 * <> -
4                   4    1

And for comparison, this is what a similar “99 bottles of beer” program looks like in Befunge. I wouldn’t say this is idiomatic Befunge; rather, it’s me trying to be clever and employ “code reuse” and “a functional style” in a language that isn’t really designed for it. My original idea was to make a “direct port” of the Flobnar code into Befunge; but I quickly realized that that was going to be a real pain, and settled for the version you see here.

v
 99 bottles of beer on the wall
 99 bottles of beer
 Take one down, pass it around
>               v
   v   ,*25$<   >92+9*v
50< >:65*0-`|            0< 1 <
50^#^+1,g1: <             ^   ^
30>>08g76p      28g39pv   ^   ^
51v^09g76p19g96p29g39p 08g 97p^
   >1-16g96p26g39p19g9 7pv     @
  > 27g39p                   :!|
        v:p12+*86%*25:<<<< ,*25<
        >52*/:68*+11p!1+  ^

In the Flobnar code, the subexpression 5*2 (in the upper left corner) is reused four times.

In the Befunge code, the most interesting cell is (x=3, y=9).

Posted 2019-05-02