Unlease the madness with
Created to match the madness of Programmers
Test the chaos below
Let’s create a simple program with both Normal and Crazy Modes:
kaboom main() {
glitch("Starting...");
crash x = 10;
glitch(x);
unleashchaos;
glitch("Chaos unleashed!");
glitch(x); // Random tweak
}
Universe 0: Starting...
Universe 0: 10
Universe 0: Chaos unleashed!
Universe 0: 12 (example with random tweak)
Declare variables with crash
, output with glitch
, and switch to Crazy Mode with unleashchaos
.
ChaosLang is a programming language designed to blend structured programming with chaotic behavior. It operates in two distinct modes:
kaboom
: Defines a function.crash
: Declares a variable.glitch
: Prints output.if
: Conditional statement.return
: Returns a value from a function.meltdown
: While loop.explode
: Breaks out of loops or functions.chaosfor
: For loop with start, end, and step.chaosforeach
: For-each loop for arrays.in
: Used in chaosforeach
loops.unleashchaos
: Activates Crazy Mode.mutate
: Redefines a function.chaoscall
: Randomly calls a function (Crazy Mode).rewind
: Reverts program state.corrupt
: Randomly modifies code (Crazy Mode).multiverse
: Runs in parallel universes (Crazy Mode).+
, -
, *
, /
, %
, ^
>
, <
, =
(flipped in Crazy Mode)|
(for quantum variables)push(value)
: Adds a value to the end.pop()
: Removes and returns the last value.shift()
: Removes and returns the first value.unshift(value)
: Adds a value to the beginning.length
: Property to get the array length.Every ChaosLang program starts with a main
function defined using the kaboom
keyword.
kaboom main() {
glitch("Hello, ChaosLang!");
}
Universe 0: Hello, ChaosLang!
Simple output in Normal Mode.
Use unleashchaos
to enable Crazy Mode.
kaboom main() {
glitch("Starting in Normal Mode...");
unleashchaos;
glitch("Now in Crazy Mode!");
}
Universe 0: Starting in Normal Mode...
Universe 0: Now in Crazy Mode!
Random shapes appear on the canvas in Crazy Mode.
kaboom main() {
crash x = 42;
glitch(x);
}
Universe 0: 42
Basic variable declaration.
kaboom main() {
crash x = 1 | 2 | 3;
glitch(x);
glitch(x);
}
Universe 0: 2
Universe 0: 3 (example)
Random value chosen each access.
kaboom main() {
glitch("Chaos is here!");
crash x = 10;
glitch(x);
}
Universe 0: Chaos is here!
Universe 0: 10
Prints strings or variables.
kaboom add(a, b) {
return a + b;
}
kaboom main() {
crash result = add(5, 3);
glitch(result);
}
Universe 0: 8
Functions with parameters and return.
kaboom main() {
crash x = 5 + 3 * 2;
glitch(x);
}
Universe 0: 11
Universe 0: true
Universe 0: false
Comparison flips in Crazy Mode.
kaboom main() {
crash x = 10;
if (x > 5) {
glitch("x is greater than 5");
}
}
Universe 0: x is greater than 5
Basic conditional logic.
chaosfor
Loopkaboom main() {
chaosfor (i = 0; 5; 1) {
glitch(i);
}
}
Universe 0: 0
Universe 0: 1
Universe 0: 2
Universe 0: 3
Universe 0: 4
Iterates with step value.
chaosforeach
Loopkaboom main() {
crash arr = [1, 2, 3];
chaosforeach (item in arr) {
glitch(item);
}
}
Universe 0: 1
Universe 0: 2
Universe 0: 3
Iterates over arrays.
meltdown
Loopkaboom main() {
crash x = 0;
meltdown (x < 3) {
glitch(x);
crash x = x + 1;
}
}
Universe 0: 0
Universe 0: 1
Universe 0: 2
While loop equivalent.
kaboom main() {
crash arr = [10, 20, 30];
glitch(arr[1]);
}
Universe 0: 20
Access elements with indices.
kaboom main() {
crash arr = [1, 2];
arr.push(3);
glitch(arr);
crash popped = arr.pop();
glitch(popped);
}
Universe 0: [1, 2, 3]
Universe 0: 3
Modify arrays with methods.
kaboom main() {
crash arr = [1, 2, 3];
glitch(arr.length);
}
Universe 0: 3
Get array length.
unleashchaos
kaboom main() {
crash x = 5;
glitch(x);
unleashchaos;
glitch(x);
}
Universe 0: 5
Universe 0: 7 (example)
Tweaks numbers and shuffles arrays.
chaoscall
kaboom sayHello() {
glitch("Hello!");
}
kaboom main() {
unleashchaos;
chaoscall;
}
Universe 0: Hello! (if chosen)
Random function call in Crazy Mode.
corrupt
kaboom main() {
crash x = 5 + 3;
glitch(x);
unleashchaos;
corrupt;
}
Universe 0: 8
Code corrupted!
Universe 0: 53 (example)
Randomly modifies code.
multiverse
kaboom main() {
crash x = 5;
unleashchaos;
multiverse;
glitch(x);
}
Universe 1: 3
Universe 2: 7 (example)
Runs in parallel universes.
kaboom greet() {
glitch("Hello!");
}
kaboom main() {
greet();
mutate greet() = {
glitch("Hi!");
};
greet();
}
Universe 0: Hello!
Universe 0: Hi!
Redefines a function.
explode
kaboom main() {
chaosfor (i = 0; 5; 1) {
glitch(i);
if (i = 2) {
explode;
}
}
}
Universe 0: 0
Universe 0: 1
Universe 0: 2
Breaks out of loops.
return
kaboom square(x) {
return x * x;
}
kaboom main() {
crash result = square(4);
glitch(result);
}
Universe 0: 16
Returns a value.
kaboom main() {
panic("Something went wrong!");
}
Chaos unleashed: Something went wrong! at line 2
Throws an error.
kaboom main() {
crash x = 1;
glitch(x);
crash x = 2;
glitch(x);
rewind 1;
}
Universe 0: 1
Universe 0: 2
Universe 0: 1
Reverts state by steps.
kaboom fibonacci(n) {
crash a = 0;
crash b = 1;
chaosfor (i = 0; n; 1) {
glitch(a);
crash temp = a + b;
crash a = b;
crash b = temp;
}
}
kaboom main() {
fibonacci(6);
}
Universe 0: 0
Universe 0: 1
Universe 0: 1
Universe 0: 2
Universe 0: 3
Universe 0: 5
Fibonacci series generation.
kaboom main() {
crash arr = [1, 2, 3];
glitch(arr);
unleashchaos;
glitch(arr); // Shuffled!
}
Universe 0: [1, 2, 3]
Universe 0: [3, 1, 2] (example)
Array shuffling in Crazy Mode.
kaboom rollDice() {
crash roll = 1 | 2 | 3 | 4 | 5 | 6;
glitch("You rolled a " + roll + "!");
}
kaboom main() {
rollDice();
rollDice();
}
Universe 0: You rolled a 2!
Universe 0: You rolled a 3!
Rolling Dice via Quantum Variables.