We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.

Ð

From Esolang
Jump to navigation Jump to search

Ð (pronounced like the in <this>) is an esoteric programming language by User:Rdococ. The goal was to explore the idea of "partial execution" of program statements, so that e.g. if a statement is "half-executed" twice the result is the same as full execution.

Overview

If you were to explain multiplication to a young child, you might describe it as repeated addition. Ð takes this concept to the extreme - for example, the below program calculates 2^3.5.

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

This function defines multiplication for the real numbers.

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

Non-trivial cases

Say this is your program.

repeat (0.5) {
    print("hello world")
}

Whatever this does, if it's done twice it should be equivalent to printing "hello world" once. You can't just print "hello" or something to that effect, since doing that twice only results in "hellohello". Some operations might not be permitted in this language at all because they cannot be divided indefinitely.

For "print" specifically, you could produce an output image instead of a string. Partially printing a string prints only an N% 'slice' of the character glyphs to output, with the idea that the "caret" only advances once a complete character (or strange chimera of characters) has been printed. Surprisingly this could have practical uses in combining glyphs.

repeat(1.5) {
     x := x * x
}

Executing the above program twice should be equivalent to squaring x 3 times, or in other words, "x := x^8". The program itself is then equivalent to "x := x^sqrt(8)". While multiplication by a constant can be "partially executed" by taking the square root of the constant, multiplication by the same variable is more like exponentiation by a constant. How this and similar cases including cases with multiple variables could be accounted for is TBD.

Halting problem?

function halts(f) {
    task := launch(f)
    if (doesNotHaltInTime(task)) {
        cancel(task)
        return halts { repeat (0.5) { f() } }
    }
    return true
}

The above function takes another function. It launches the function in a separate thread or process, and if it doesn't halt in some finite time it cancels the task and tries again with the half-execution of the given function. I believe this does not solve the halting problem, however - you can shrink execution times arbitrarily low to prove that some very long-lasting programs halt, but the overhead of waiting the specified time per iteration means that this function does not halt on a non-halting input program and cannot prove that the program does not halt.

All of this assumes that partially executing a program takes a time proportional to its full execution, which is probably not a safe assumption to make.