Imaginary PLT: Nonperformative
Nonperformative is a concatenative programming language. It's main influences are Mirth, Factor, and Joy. It features multiple stacks to facilitate in sharing values between operations. It's main control-flow structure is the case block.
The following is an implementation of factorial in Nonperformative:
: factorial
>n 1 >acc try-factorial ;
: try-factorial
10 roll @n case
of [ 1 ] [ 0 ] [ factorial-done ]
of [ 1 ] [ _ ] [ do-factorial ]
of [ 2 ] [ 0 ] [ factorial-done ]
of [ 2 ] [ _ ] [ do-factorial ]
of [ 3 ] [ 0 ] [ factorial-done ]
of [ 3 ] [ _ ] [ do-factorial ]
of [ 4 ] [ 0 ] [ factorial-done ]
of [ 4 ] [ _ ] [ do-factorial ]
of [ 5 ] [ 0 ] [ factorial-done ]
of [ 5 ] [ _ ] [ do-factorial ]
of [ 6 ] [ 0 ] [ factorial-done ]
of [ 6 ] [ _ ] [ do-factorial ]
of [ 7 ] [ 0 ] [ factorial-done ]
of [ 7 ] [ _ ] [ do-factorial ]
of [ 8 ] [ 0 ] [ factorial-done ]
of [ 8 ] [ _ ] [ do-factorial ]
of [ 9 ] [ 0 ] [ factorial-done ]
of [ 9 ] [ _ ] [ do-factorial ]
of [ 10 ] [ 0 ] [ factorial-done ]
of [ 10 ] [ _ ] [ do-factorial ]
end ;
: do-factorial
!acc(@n *) !n(1 -) try-factorial ;
: factorial-done
n! acc> ;
: main
10 factorial ;
factorial is a helper function which which wraps the factorial* function. Each step of factorial* first rolls a 10 side dice. This is used to randomize the branches of the case statement. factorial-done implements the base case, while do-factorial implements the recursive case.
The repitition of code is required.
Before a function is executed, any case blocks it contain will speculate on which branch will be taken. If a guess is incorrect, Nonperformative will take note. The probability table for that case block is adjust for future predictions.
Typically, this is used for speculative exicution (a technique used to improve code performance) (until it cause major security problems). However, Nonperformative has no interest in running making code faster. If a conditional branch is correctly predicted, the assocated computations are not executed. Execution continues as if the code never existed.
Perhaps there is nothing faster than not executing code? So maybe Nonperformative is the most preformance focused language in existance.
For a program to run correctly, its path of execution must be randomized. All functions with conditional laogic become a game of cat-and-mouse. Where the programmer repeatedly recites their lines of code in a desperate plea for good fortune. The longer a program is expected to run, the more lines of probabilistic obfuscation it will need.
A program expected to run forever, must in turn, be infinitely long. This calls into question if Nonperformative is Turing complete.
Inspiration
Language idea was inspired by the prompt for Language 17 from FORTY-FOUR Esolangs by Daniel Temkin:
a programming language that only values the unexpected.
if the interpreter can predict whether the program will halt, it will not bother carrying it out.