CTFE and DI: The Crossroads of D

H. S. Teoh hsteoh at quickfur.ath.cx
Thu May 10 13:52:25 PDT 2012


On Thu, May 10, 2012 at 03:39:47PM -0400, Nick Sabalausky wrote:
[...]
> > The only thing that can come close to being uncrackable is something
> > that's so hard to use that most people wouldn't bother with it.
> > Which gave me a funny thought: one way of writing code that nobody
> > can steal is to write it in MALBOLGE
> > (http://www.lscheffer.com/malbolge.shtml).
> 
> Geez that's insane! And I thought brainfuck was nuts.
[...]

Welcome to the weird and wonderful world of esolangs. :-) BF was just
the beginning of the madness. INTERCAL is an amusing esolang in which
you have to insert adequate amounts of the PLEASE command, otherwise you
risk instant program termination. Then there's Java2K, which is a
probabilistic language, in the sense that all operations only have a 90%
chance of actually returning the correct result -- so the challenge is
how to write code in such a way that the probability of your program
producing the desired output is as close to 100% as you can get (it's
not possible to guarantee 100% correctness... but then, what programming
language can guarantee that? :-P).

There's also Befunge and its spawn, in which the program counter is a
vector rather than a counter, and program code is written on an
n-dimensional grid. The neat thing about Befunge is that there's no
special syntax for comments: you just write comments in-place and route
your PC around the comment text. :-) (Clever programmers could, in
theory, route certain program paths through comments to ensure that
comments are always up-to-date with the code. :-P)

In fact, I myself wrote a Befunge-like esolang once (when I was really,
really, REALLY bored). My esolang is even weirder than Befunge in that
it doesn't even have a program counter. Instead, the code consists of
symbols written in a 4-dimensional array, and every iteration, every
element of the array is "executed". Some symbols are passive (they don't
do anything when "executed") and other symbols are active: they erase
themselves from the current location and write themselves into a
neighbouring location in the array. Based on the symbol in the target
array cell, different things happen.

The result is a bizarre physics-like simulation where active symbols
(aka particles, representing binary 1 and 0) fly around in a 4D array,
get reflected/duplicated by reflectors, and trigger output by
simultaneously striking the output symbol in groups of 8, representing 8
bits of the output character (now you know what I chose a 4D array: in
4D, there are exactly 8 neighbours surrounding each cell). The hello
world program, for example, looks like this:

    ..%..     ..}..     ..%..     .....     .....
   ..'..     .v...     .. at v.     .....     ..,..
  ..-..     .....     %)%..     .v at ..     ..,..
 .....     ..v..     '....     ...V.     ..,..
.....     @....     %(<..     @....     ..%..
    .. at ..     .+...     ..V,.     .....     ....@
   .}...     )!<].     .{)!<     .+.{.     .....
  .....     .'+..     @]v-.     )!<+.     .{...
 ..]..     .)!<.     ..{].     .-)!<     ...{.
.....     ..-..     .....     ...-.     ..v..
    ..%..     .. at ..     ..%..     .....     .>))%
   ..+..     .^.v.     .V+A.     .....     ....+
  %@%..     }.]..     %)!(%     .^{V[     ..%@%
 '....     .V^..     ..-..     ...A.     ..'..
%((..     @....     ..%..     .. at ..     ..%..
    ..A..     ...,.     .,...     .....     ....@
   ...].     .])!(     )!<{.     .[.+.     .....
  @....     .,.'.     @-^].     ..)!<     @.^{.
 .]...     )!<..     .[...     ...-.     .....
.....     .'...     ..A..     .....     .. at ..
    ..%..     ..[..     ..{..     .....     .....
   .....     ...^.     .A...     .....     .....
  %<(..     }....     %)%..     @..A.     .....
 .. at ..     .^...     .. at ..     .....     .....
))%..     ..]..     ..%..     .....     .....


This program is written on a 5x5x5x5 array, which is represented in
ASCII as a 5x5 grid of slanted 5x5 grids (thus covering all 4
dimensions). Why slanted? 'cos the perspective makes it clearer
(*ahem*cough*) that they're slanting into the 3rd dimension.

Granted, though, MALBOLGE takes the cake in terms of difficulty of
implementation. My esolang is just a matter of routing and synchronizing
the movement of particles so that they strike the output operator at the
right times to produce the desired sequence of ASCII characters.
MALBOLGE, OTOH, is so insanely twisted that no amount of rationalization
will ever give you a working model of mapping desired semantics to code.


T

-- 
Some days you win; most days you lose.


More information about the Digitalmars-d mailing list