Ð

From Esolang
Jump to navigation Jump to search
This esoteric programming language is still a work in progress. It may and probably will change in the future.

Ð (pronounced like the in <this>) is a work-in-progress design for an esoteric programming language by User:Rdococ.

Purpose

Ð's purpose is to be cool and unusual. Whether it succeeds or not tends to either be up to you, or up to whether pigs fly. Of course, in Ð, pigs sometimes like to half-fly - which is kind of odd if you ask me.

Overview

If you were to explain multiplication to a young child, you may mention something about repeated addition. Ð takes this concept to its extremes. Here is an example of what I mean - it's valid and outputs 11.3137084989848, the approximate value of 2^3.5.

x := 1
repeat(3.5) {
     x := x * 2
}
print(x)

Actually, multiplication itself is defined like this:

function multiply(x, y) {
     a := 0
     repeat(y) {
          a := a + x
     }
     return a
}

Another example of Ð's unusual semantics:

x := 23
print("hi")
repeat(1.5) {
     if (x < 23) {
          print("hi")
     } else {
          x := 22
     }
}

is also valid. To understand what it prints out, we must follow the logic of the output stream. When "print" is called, the output is shifted to the left by n+1 bits - we can view this as it being multiplied by 2^(n+1), where n is the length of the string to print out. Then the string itself is printed (after the newline, of course). So say the above was a repeat(2) as opposed to a repeat(1.5):

01101000 01101001 // ascii for "hi"
01101000 01101001 00000000 00000000 00000000 // 26729 * 2^3 = 8
01101000 01101001 00001010 01101000 01101001 // append 00001010 01101000 01101001 ("\nhi")

So, in the repeat(1.5) situation:

01101000 01101001 // ascii for "hi"
1 00100111 01010001 // 26729 * (8^0.5 =  2.82842712474619) = 10010011101010001_2 rounded down
101 10011100 10011101 // append /half/ of (00001010 01101000 01101001 = 682089) ("\nhi"), which is 341,044 rounded down

You get some gibberish, basically.