I decided that for today, I’d show the most thoroughly evil programming language ever
devised. This is a language so thoroughly evil that it’s named Malbolge after a circle
of hell. It’s so evil that it’s own designer was not able to write a hello world program! In
fact, the only way that anyone managed to write a “Hello World” was by designing a genetic algorithm
to create one. This monstrosity is so thoroughly twisted that I decided to put it in the “Brain and Behavior” category on ScienceBlogs, because it’s a demonstration of what happens when you take a brain, and twist it until it breaks.
What makes it so thoroughly evil?
- It’s based on trinary.
- All programs consist of nothing but a sequence of numbers.
- Opcodes are not allowed in the source code. All opcodes must
be encrypted using a very silly encryption scheme.
The Malbolge interpreter has three registers, named “C” (code),
“D” (data), and “A” (accumulator). It’s also got a memory – each address in memory can store a value that is 10 trinary digits wide.
The way that code works is that it loads the value in the memory cell addressed by C. That value is added to the current contents of “C”,
and then it takes the remainder of dividing that sum by 94. The result
is an opcode. Oh, and just for the sake of annoyingness, if the value of
the cell referenced by “C” is not in the range 33-126 (base 10),
then the program terminates with an error.
The opcodes that can be used in a Malbolge program are:
Opcode | Description |
---|---|
4 | Set C to the value pointed at by D |
5 | Output A mod 256 |
23 | Input a character to A. |
39 | Set A = the value pointed at by D, then trinary rotate right one digit. |
40 | Set D = the value pointed at by D. |
62 | Tritwise operation (to be described below) |
68 | Noop |
81 | Halt |
For opcode 62, what you do is take each trinary digit d of the cell referenced by D, and each trinary digit a of the contents of A, and then look
in the following table for the result for that trinary digit.
a | d | result |
---|---|---|
0 | 0 | 1 |
0 | 1 | 1 |
0 | 2 | 2 |
1 | 0 | 0 |
1 | 1 | 0 |
1 | 2 | 2 |
2 | 0 | 0 |
2 | 1 | 2 |
2 | 2 | 1 |
Once the opcode is complete, if the opcode modified A, then the resulting
value of A is stored into the memory cell referenced by D. If the opcode did not modify
C, then C is incremented by 1. Finally, if the contents of
the cell pointed at by C are in the range 33-126 (the range of ASCII printable characters), then
they’re translated up in the following table, and exchanged for the value of
the ASCII code of the character in the same position in the other row:
5z]&gqtyfr$(we4{WP)H-Zn,[%3dL+Q;>U!pJS72FhOA1C B6v^=I_0/8|jsb9m<.TVac`uY*MK'X~xDl}REokN:#?G"i@
(In the original version of this post, in the above paragraph, I accidentally omitted the
clause about how/when the value of A is stored to memory; I also originally forgot to mention the wy that C is incremented.)
Now, finally, the first hello world program in Malbolge:
(=<`$9]7<5YXz7wT.3, +O/o'K%$H"'~D|#z@b= `{^Lx8%$Xmrkpohm-kN i;gsedcba`_^][ZYXW VUTSRQPONMLKJIHGFED CBA@?>=<;:9876543s+ O<oLm
Don’t ask me to explain how it works. I don’t understand it either.
For an example of a kinda-sorta-realish program in Malbolge, here’s an
implementation of a program that prints the lyrics of the “99 Bottles of Beer” song:
b'`;$9!=IlXFiVwwvtPO0)pon%IHGFDV|dd@Q=+^:('&Y$#m!1S|.QOO=v('98$65aCB}0i.Tw+QPU'7qK#I20jiDVgG S(bt<%@#!7~|4{y1xv.us+rp(om%lj"ig}fd"cx``uz]rwvYnslkTonPfOjiKgJeG]EC_X]@[Z<R;VU7S6QP2N1LK-I ,GF(D'BA#?>7~;:9y16w43s10)p-,l*#(i&%e#d!~``{tyxZpuXsrTTongOkdMhg`Hd]ba`_^W@[ZYXW9UNSRQPOHMLK J-++FE''<A$?>=<;:387xw43s10/(-&m*)('&}${d!~}|^zyxwvutmVqpiRQlkjiKafedcE`_^@[ZYX;V9NMRQ42NG LK.IH*F?DCBA$#>7~;{{8xx5uu2rr/oo,ll)ii&f|e"!aw`{zr[vXnmVTpongPkNihgJ_dcFa`B^]UZ=RWV8TSLQ4O N0LE.IHA)E>'BA:?!7~5|38y6/v321q).-&m*)i'&%|{d!~}_{zswvutsUqTonPlOjiKgJedFbE`_A]@[Z<X;VU7S6Q P22GL/JIB+FEDC%;@?>7~;:987w5v32r0)p-,+k)('~g$#"b~w|uz]xwvutsrqTinQlOjLhgfeH]bE`CB]>ZSXWVUTS RQPON1LE.I,+*((&&">=<|4{2ywwu321q)p'nl*k('gg${"c~a`^z]xwvYtmrUpSRPlOMMbK`IGGEE Z_^]?U>S<::8866442200.JIH*@)>C&A@?"=<5|{8y65vtt10/(-n+lk"'&%e{dyb``^^\ZvutVlUjSQmlkMcLaJHHF bECCX][=S<Q:886R5PON1LKJCH+F)(=BA@"8!6}{{2y0543s+r)pnnlljjhhffddbb`|_zyx[vutslUTSQQOOMihgI_ H]FDDBB@@>><XWV8N7L5331MLK-C,A*(D'BA$""=<;:927xwvt2s0/p-n+*)('~%f#dcaa__]yZZotsrTjShQOkjiKa J_HFFDDBB@@>><X;99NS6QPO2MLKJIHA*E('%%:#8=~;:9z7654321*/p-,m*k(hh}$#dyb}`{zy[qZoXVVTTRnmlNdM bKIIGGEECCAA?[>YXWP9T76K42200.JI+G@)>'%A@?!7~5|zzx654t,s*qo-n+*jj!h%fec!b}|{^s[vYWWlqTonQlO jchKfIHFFDDB^]>T=R;P9NS6QPO2MLE.-,*FED&<%:#!!}}{{yyw543s+r)pnnl*kii~%f#"caa|{zsx[ZutVrkTinQ lkNiLgfe^cFEDYBW[=YR;P977553O200EJIH*@)>C&""~<}:9zxx5 4-tsrp.o,+l)j'&}f#d!~}_u^sZZXXVrqpRhQfOMihJf_H]FDDB^]>T=R;99775Q4ON00KJIBG*E('%A$?>=~;:927 xwvttr0/.n,m$)('g}f{"c~}`{^yxwvoXsVUSShQOkjLhaJ_HFba`BXAV?=YX:VO8M644220L/JI++FEDCB;@#>!<;:z 2y05v321r/.-,+$)j'hgeeccaa__]][wZXXmVkTiRPPNjMhgfIdcba`_XA@?==;;9977L5J31MLK-C,A*((&BA@"8!6} {{y765u-t+rppn,m*)j'h%$#"!~}v{^y[YutsUkTiRPPNNLhgfH^GECCAA??==;;9UTS5K4IN1LKJC,G*)''%%#?>= }5|3zxxvvttrrppnnl*k('gg|e"c~a__tywvuXmVUTinmlNdMbKIedFb[DYB@?==RWVU7M6K42N1LK.,,G@E('&$@# >=~;|927xw4uss*/.n,%l#(i&%f#d!~w`{^][[YYWWlUjonmOeNcLJJHHFFDDB^A[==XWVOT7R542N1LKJ-HGF?D'&% :?"=<}:3z7xwuussqqo-,+k#j!h}fddb~}_{t]r[YYWWUqpoQgPeNLLJJHHFFDDBB@@>Z=XWV9N7R54I2GLKJ,B+@)'' %%#?>=}5|3zx654t,s*qoommkkiig%f#"bb}v{^ywvuWmVkpSnmlOjchKJIGGEaD_^A?ZYR;V986RQP2H1F/--++)) ''%%##!=~;:zz765.3t1rq(-,+k#j!&g$#"c~}|uz]x[ZXtsrTjShQOOMMKKIIGGEECCAA?[><<QV9TSR5PONMF/.-+G FE'=&;$""~~||zzxxvvttrrp.o,+ljj'&%$#z!ba|_]]rwZutWrUponmlejMLKIIGGEECCX][=S<Q:8TSR4J3H1F/DI ,GF)D'BA@?>=6}|9zxx/432r*q(o&mk)j'&g$e"!~}|{zsx[vYXVVTponPfOdMbKIIGGECCAA??=YXW9O8MR5PONG0K .I,**?D'BA@9"=~}4{yywwuussqqoommkki'h%$ddyb}`_tyZZotsrTjShmPkjiLaJIHFba`BXAV?==;;9977553311 //-IHG)?(=B%@?"=~;49z7x543s+r)pnnl*)(h~g|ec!b``uzyxZpYnWUqpoQgPeNLLJJHHFFD`C^]??ZYR;V986R5PO N1LKD-,+))''%%##!=<;{3z1xvvttrrppn,mkk"'&f${dy~a|{^\wvunsVUpSQQfkNihKfIdcb[`C^A[Z<R;PUT6RQ 4I2GL/JIH+FEDC<%@#"~~|:98x0w.ussqqoommkkiigge#"!aw`uz]xwYYtsrqpinQlOjMKK`eHcbaD_^][TY<;:O86 R5PO2MF/J-,A*((&BA@"8!6}{{yywwu3trr).-,l$k"igge#dbbw|{zr[pYWsVqpRRgPkNMKgJedcF[D_B]>ZS<QV9 TS55POH1L/J-++@E(CBA$?>7~;|{y76v4-t+rp.-,l$k"iggeecca}`{z\wvunsVqTonPleNchKfedGba`Y^A@?==;W VU7M6K42N1//DIHG)?(=&""~~||zzxx/4u210q.-&+l)jig%$d"ybw|_zyx[vunsVUTRnmlNdMbKIIGGEa `B^W@U><<::88664PON0F/DI,GF)D'BA@9"=~}4{yy0wuus10/o'n%ljjh&%$dzcxa__]][wvXtmVkTRRPPNjMhgIIdc baZ_B]@[ZY;Q:OT7RQP3NMLKDI,+FED&<%:#!=<|:3z1xvvttrrppnnlljjh&g$#d!b}|{zyr[vYXVrqpRhQfOMMKKII GGEECCAA??=Y<WV88SRQPONGL/J-HGF(>'<A$?>=~;:9876/4utsq/pnn%*)i'~g|ec!b}|_z]xwvutsrkToRQOkjiKa J_HFFDDBB@?==RWV8TM6K42NML.D-B+))'C&A@""=<;:9876/4u2s0/o-&m$)j'&%f#"!~}|{zsx[vuXsVqSShmlOdM hKJ_HFFDDBB@[Z<R;P977553311//--++)E(CBA:#"!6}{{yyww.us10/o'n%ljjhhf$#"bxav_]yxwYoXmVTTRRPPN NLhKfeHFF[DC^]>T=RW:UT7R5J32M0KJ-++F?D'&A@">7~5:{87xvv32+rq.omm$)j'&g$e"!xa|_^xwYunWlUSonm OeNcLJJHHFFDDBB@@>Z=XW99TSRKP3N10.J-HGF)DCB;@#"!6}{{y765u-t+rppn,+*j"i~geeccaa__]][wZutWUUpo nmfONihgI_H]bE`_B]@[ZYXQ:9T755JO200E.CHGF(>'<A$?>!<}:9876/4utsq/.-m%l#jhhf$#c!xav_]][[YuXsrU pSnmlkjchKJIGGEa`_AW@U><<::8TS5QJ3H1/KJI+A*?(&&$@#>=~||9876543,1rq.-m+$k"'h%$e"c~}|{zyxqvYXs VTTinmlNdMbgJedGbE`_^][ZYR;:9775QPO1M0EJ-HG*E>'B%$9"~~||zzxxvvttrrppn,m*)ii~%f#d!b``uz]xwvY nsVqTSQQOkjiKaJ_HFFDDBB@@>><<::886R5PON1LE.-H+))>'<A@?!7~5|z8y65v3t10).onmkkiiggeec!~}_u^sZ ZXXVrqSohQfOMMKKIeHcbE`C^]V[>Y<;P977553311//--++)EDC%;$9"7~5:{876w432+rqpnn%lj('g%|ezcaa__]y wvYtWrqpohmPkNMKKIIGGEECCAA??==;W:88MR5PON1LKJIHA*)(=&9>!<;|92yx543s+r)p'n%lj(i &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'~g|ec!~}_u^sZZXXVVTTRRPPNNLhKfeHcFa`_^]V?>Y<WV97M6542NML.J-BG*ED'B; $?"!}}{{y76v43t+0/o-&m$kiig%fddy~}_{t]rwZutVVkpSnQPNjMhgfI^cFE`CAAV[ZY;Q:OT755JO2ML/J-HA*)D' BA$""=<5:{8y654t,10/.o,+$)jihffddbb``^^\ZZXXVrqpRhQfkNLLafIdcFaD_^]V?>YXW9O8M6442200.JIH*@) >'%A$?>!}}:98705vutr0q.-n+l)('&}$e"cbw`^zyxZpYnWUUSonmOeNcLJJHdcEaZCXA??==;W:UT66QPONMF/J-HG F(>'<A$?>=~;:9870w4ut+0/o-&m$kiiggeeccaa__]yxwYoXmrUponQlkjihg`eHcFECCX]@>>SX;VUT7RQPONMFK.I ,+@E(&&;@?>~6}49zxx/4u210)p-n+ljj!&g$#"yb}`_t][wvuWmVkTRRPPNNLLJJHHFFDDB^A[Z=R;:97SRQ3I2G0. .,,**((&&;$">=};4{2yw5v32s0q.',m*k('g%|ezcaa__]][[YYWWUUSSQmPNNchKfeGGbaZC^A[Z<R;PU8SRQ4ONG 0/JIH*@)>'%%:?>=}5|3zx654t,s*qo-n+*k(i&%${"cb}|{]sqZXXmrqSohQfkNihKfIdcb[`CBAV?=YXW9O8MR5PO 200KJIHA*)(=B%@?"=~;:981xwvt210p(o&+l)(i&}f#dcaa__]][[pYWWUqpRngPeNLLJfedFEZCAA??==R;9U8SRQ 4IN10/--++)E(CB%##>7~}|3876v.u,sqqoommkkiig%$#cybw|_zywZunWVUSoRPPejiKg`I^GEECCAA??=YXW9O8M 64P3NM0..IHAF)('%A$?>!<}:927x5vussqqoom+*j(!h}fddb~}|^t]r[pYnWUqTonPPkjibKfIdcbDZCX]@[ZY<WVU N7653ONM/K.CH+FE(C&A@?>7<}|{yywwu321q)p'nlljjhhf$#"bxav_]][wZXXmrqpRhQfOMMKgJedGbE`_^]U>=X; VU86L5P32GL/JIHA*E('<%:#8=~;:9z16wvus10p.-n%*)i'~g|ecca}`^^sxwYunWlUSoRmlOjMhaJIHFba`BXAV?== ;WV8TM6K4220LKJ,B+@)''%%##!!};|98yww43,1rq.omm$)j'&g$e"!x}`{^yxwYoXmVTTRRPlkjLbK`IGcbaCYBW@> ><<::88664P3NM//JIHA*E(C&""~~5:9y70w.3t10q.o,+*)('~%fe"caav_tyZZotWrqToRmlkjihafIdG F[DBB@@U><XWV8N7L53311//--++))'C&""~~||z876v.u,1r/.o,m*#j'h%fddy ~a__t]r[puXsrqTonglONiLJJ_dGEEZ_B]?Z=XWVO8S6Q422GL/--BG*EDC&A@?>7<}|{yywwuussqqoom+ljj!h}$e "!b}`{zyxwpYtWrUSShmPNNchKfedGba`_^]V[>=<:VUT6L5J311//-IHG)?(=&9"7<} :9z7x5.u2s0qoo&+ljj!&g$#"c~}v{^]xwvXnWlUSonmOeNcLJJHHFFDDBB@@>><<:V9TS6Q4ONMF/J-H+))>C&""~~||zzx654t,s*/p-,m*k('&%$#zc~a`^^\ZvuWslUjSQQOOMMKKIIGGEaDBBW? ZYX;VUTSRQPIN10/D-++))>C&A@#>!<;:98765.u2srp.-,l$k"iggeeccaa__]][[YutsUkTinQlkjcLgJI^cbD`YBW @>Z=XWV9NS6Q4311F/--+GF(D=&;$">=<|4{2ywwuussqqo-n+*)j'~g$e"!a}v_t][[YutsUkTiRPPNNLLJJHH]FDDB B@?ZYX;VUNS6Q4311FKJI+A*?(&&""~~||zzxxv4u210q.-,%lk(igg|#dbbw|_zywZu tsrkpSnQPNjihJ`I^GEaDBBW[=YR;P9775QPO1G0E.,,**((&&">=<|4{2ywwu321 q)p'nlljjhhff{"c~}|_zyxwpYtWVTTRRPPNNLLJJ_dcbDZCXA??==;;99775Q4ONM0KJIHG@E('BA@"8!6}{987w/v- trrppnnlljjhhffddb~a|{^ywvutsrkToRQOkNLLaJ_H]ba`BXAV?==;;9977553311//-I,GFE>'B%$""~~||z876v .u,sqqoommkkiig%f#"!bw|_z]ZZoXVrqpRhQfOMMKKIIGGEECCAA?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!}}|?.Z=;QPtTq %4o31kj/WIyfSRbC<`MLo<|k{2V0fv-Qb=q.o&JH#G4~V$Bdy>P_;](x8vH5"3UpSh.fe=ib(J%7cF!`2B{i.Z<wuPt 'qLQn"2~YK-hBG)ccC<NM]K7}|Y{i1U/Ad2sO/LoJIkZFEhf$TA!~>+{]]88Y6XslT0B.zl,=<;(J%d]F!`}BW@yyY+d tO8Mq5PINkjih-BTecQCa`qp>J~5XzW165eR,bO/L^m8[6j'D%UBdc>}`N^9x&vonF2qCSRmf>M*;J&8^]n~}}@?[xY +:Pt8S6o]3l~Y..,,*@RQ
So. Pointless? Yes. Evil? Absolutely.
Help me out here please… it may be obvious to other people, but I can’t see why this is a “language” (equivalent to a Turing machine). If I’m right, it does input and output, and reading from data, but there’s no sign of branching or recursion, no way that I see to store data.
All I can say is wow.
Michael:
Your confusion springs from two things – how to alter
memory, and how to do control flow. And in both cases, it’s because I screwed up 🙂
The first confusion. I accidentally left something out of the description: each of the operations that modifies A (including input, tritwise, etc.) also store the result value into the memory cell referenced by D. I meant to include a sentence after the opcode descriptions saying that.
The second is more twisted. There isn’t really any control
flow operation in Malbolge. There are two different ways to do control flow in Malbolge.
One is computed branches. The address of the next instruction to execute is the value in the C register. So
opcode 4 is basically an unconditional branch instruction; it sets the address of the next instruction to execute. But
it’s not a fixed branch – it’s a branch to a computed address – to whatever you stored in the address pointed at by D.
The other way to do control flow is self-modifying code. The code space and the data space are the same – so your code can modify itself. There are actually some examples on the web of self-modifying Malbolge programs; frankly, how anyone can figure out how to write a program in this language that manages to compute how to update the program to do something is completely beyond me, but people have done it! (Sick, twisted people, but smart sick twisted people.)
If you look a few hundred characters back in the 99 bottles song it says ‘geez!’
It’s got that right.
The COW implementation of 99 Bottles of Beer is far more efficient 😉
http://www.bigzaphod.org/cow/
Ben: it actually seems to contain that string four or five times. So it’s definitely got that right. 🙂
If I remember correctly, a lot of malbolge programming involves finding cycles in the encryption scheme, such that you return to a certain value after N program steps. I know there’s a trivial (and useless) 2-cycle, but then there are several of larger sizes. Once you’ve found a cycle, you can manipulate it to get some form of controlled program flow.
That’s sick, just sick.
But then, I’m doing C/C++ code reviews for junior programmers today and some of them seem to have been inspired by Malbolge. Where does this instinct come from — to do things in the most obscure and indirect way possible?
I now want more on the genetic algorithm that was able to write the Hello World program.
I want to know about the genetic algorithm that came up with the 99 bottles program!
Mark CC said: “In fact, the only way that anyone managed to write a ‘Hello World’ was by designing a genetic algorithm to create one.”
…illustrating a too-often-neglected point: Folks erroneously assume that it’s always *easier* to make something complex via intentionality versus descent-with-modification.
Approaching the same point from the opposite direction: A couple of days ago, a friend showed me that day’s entry in her Far Side calendar (dang, I miss that cartoon). There’s Larson’s usual chubby, freckle-faced kid, staring at a desktop with the shattered remnants of a test tube on it. His glasses are knocked askew, and his face looks singed. There are feathers *everywhere*. The caption (inexactly, from memory) is, “God as a kid in His room tries to make a chicken.”
I suspect they’re essentially the same program.
Mark:
Thanks. Knowing that come opcodes write to the memory cells makes it… seem possible. (I wanted to say something like “…all make sense”, but I don’t think this language can ever be said to make sense.)
I think it’s interesting that useful results can be generated from a genetic algorithm (GA). I’ve long wondered whether there was a language so twisted that GAs were the only viable way to write programs, yet simultaneously efficient enough that the programs thus written might be useful. (Given the length of 99 bottles, I’d say this language fails, at least with this GA).
Although the first Malbolge programs were created using GA to evolve a particular output string, people have later managed to analyze the language enough to make some programs with a more direct approach. In particular the above 99 bottles program by Hisashi Iizawa uses actual looping.
Actually the bit about GA is inaccurate. At first the description of the language scared almost everyone who tried to use it and Andrew Cooke’s approach (A.C. was the author of that GA) did not walk the analytic way but the monte-carlo-like one (only some years later Lou Scheffer did a cryptanalisis of Malbolge, opening the analytic way).
Some time later, however, someone noticed that with a bit of patience it was easier than it initially looked to generate constant-text output, since the last encryption step after executing an instruction was irrelevant if no jumps were present at all and with some operator combinations it was possible to get the desired value modulo 256. Among others, a fake 99-bottles-of-beer program with constant-text output was created proving this principle: Schindelin’s version. There are also other hello-world programs around; a simple one is at the Wikipedia.
This 99-bottles-of-beer program, however, actually does have control flow structures et al. It is a fine piece of work by Hisashi Iizawa. Sadly the length of the program is greater than the length of the lyrics, a circumstance that could cast a shade of doubt on the reality of the claim. But after analyzing it I’m convinced it does what it claims. See my comment at the reference site of 99-b-o-b.
In no way this program can be generated by a genetic algorithm, just like a regular C program that performs e.g. an enterprise’s accounting can’t be so either. It’s possible that the initialization phase (which is the gross of the program as one can expect; see my article on Malbolge programming#Initialization_of_memory about that) was aided by a GA to get the desired values into their places. Not sure about this. But those values were not genetically generated; they were very well studied.
Now that I’m here, Mark, would you please fix the first four lines so that the & look like & ? Thanks!
— Pedro Gimeno
You just *have* to be kidding!
But seriously, suppose you have a genetic algorithm to write programs in this language. Can the genetic algorithm write a genetic algorithm?
I do esoteric programming too sometimes, and I also invented some esoteric programming languages and wrote some programs with some of them. Some esoteric programming languages are not even computable