REBMU: Code Golf Language for Humans

Code Golf is the recreational pursuit of solving programming problems in as few characters of ASCII source code as possible. Rebmu is a language tailored to winning such challenges (hopefully!)—with several twists. One is that it specifically emphasizes the ability for humans to read, absorb and maintain the source code without assistive tools, despite their compression.
Here is the “long way” to express a Rebmu program which reads a string of Roman Numerals from the input console, and then converts it into a decimal equivalent:
r s
fe c s [
n: se [x 10 i 1 v 5 l 50 c 100 d 500 m 1000] tw c
i ~ j [j: n cn]
k: k + el j n [al n - j n: 0] 'j j: n
]
k + jWhen the shorthands above are mapped into the commands they represent, this reads very naturally. r s means “read in the string s”. fe c s says “foreach character c in the string s, do the following code block”. i ~ j means “if not j do the following codeblock”. It’s straightforward, but there’s more here than meets the eye in terms of the type system etc. I’ll get to that in a moment, but…
…to put the language on the map for Code Golf, I threw in a gimmick. Since Rebmu isn’t case-sensitive in terms of its identifier lookup, it lets you use the alternation of upper and lower case characters to separate words. The process is called “mushing”—and though purely optional it can empirically save about 40% on the character count:
rSfeCs[Nse[x10i1v5l50c100d500m1000]twCi~j[JnCN]Kk+elJn[alN-j N0]'jJn]k+j
Separations are in character runs (ABCdefGHIjkl) instead of using an uppercase character to indicate each break (AbcDefGhiJkl). This is so that the special choice of when to capitalize the letters of the first word in a group can indicate whether it represents an assignment or not. So ABCdef gives you abc: def (an assignment of def to abc) while abcDEF gives you abc def (two separate words, abc and def).
Trying to read it for the first time is a little bit like stumbling over Pig Latin before you know the trick. But once your brain “gets it”, the transformation is pretty transparent. Well, at least compared to other character count reduction methods…like converting to base-64! (That may sound outrageous, but people actually submit “winning” entries that are all hexadecimal-encoded machine code… I’m not kidding.)
I’ll have more to say about this language as it develops. But the “Ace in the Hole” is that Rebmu is actually a dialect implementing a superset of the Rebol Programming Language. That means Rebmu isn’t just a toy—it can speak internet protocols, handle Unicode, and draw GUIs. And the interpreter is shockingly small—delegating most all parsing issues to Rebol, and preserving as much of the original language’s character so that knowledge transfers easily.
I introduced it the night I thought of it, on 8-Jan-2010 in a blog post modest-proposal-for-code-golf-in-rebol. At that point it was only an idea with no implementation. Since then I’ve uploaded a very preliminary version to GitHub:
http://github.com/hostilefork/rebmu/
I’m hammering through the implementation by (of course) trying to hack up some solutions to old Code Golf problems. That does introduce the risk that I might subconsciously tailor the system to narrowly solve only those problems succinctly. Yet just like in real golf, a proper game of code golf is not played in one hole and then a winner declared. The true test of Rebmu’s chutzpah will be when it is used to play several games with no modifications to the language during that tournament.
YOU CAN HELP! If Code Golf is an interesting game to you, or Rebol an interesting language (or both) then I invite your collaboration!
(Note: If you believe Code Golf is of dubious benefit, I know where you’re coming from. But I think the key is that practicing problem solving of any kind under constraints leads one to stretch into new ways of thinking. Some other opinions on this matter are in this StackOverflow question)
