Ivory

From Esolang
Jump to navigation Jump to search

Ivory is a Turing-complete esoteric programming language and hybrid Virtual Machine created by Kavindu Widyarathne in February 2026. It was created as a Valentine's Day gift for his girlfriend, notable among esoteric languages for incorporating its romantic origins directly into its temporal pacing.

Architecture & Memory Model

Unlike standard Trivial Brainfuck Substitutions (TBS), Ivory extends the traditional tape-memory computational model into a hybrid architecture.

The execution environment consists of two primary memory structures:

  1. The Tape: A standard 30,000-cell array of 8-bit unsigned integers (unsigned char).
  2. The Stack: An infinitely expanding LIFO (Last-In, First-Out) stack used for O(1) state preservation and retrieval, operating independently of the tape pointer.

The Whisper Constraint

Ivory sacrifices standard computational speed for aesthetic pacing. The language enforces what the author calls the "Whisper Constraint". Every time a character is outputted to the standard stream, the host thread is suspended for exactly 50 milliseconds. This hardcoded delay ensures that the output is generated at a deliberate, human-like typing pace, originally intended for the dramatic delivery of a compiled poem.

Instruction Set

Ivory utilizes 19 distinct opcodes, mapped using romantic keywords. Unrecognized words are completely ignored, functioning as implicit comments and allowing source code to read like stream-of-consciousness prose.

Core Turing Operations

  • adore : Increment the current cell by 1 (+).
  • miss : Decrement the current cell by 1 (-).
  • hold : Move the data pointer right (>).
  • release : Move the data pointer left (<).

Flow Control & I/O

  • whisper : Output the current cell's ASCII value (triggers a 50ms thread sleep).
  • listen : Accept a single byte of input to the current cell.
  • promise : Jump past the matching always if the current cell is 0 ([).
  • always : Jump back to the matching promise if the current cell is non-zero (]).

Stack Operations

  • cherish : Push the current cell's value onto the top of the LIFO stack.
  • reminisce : Pop the top value from the stack and overwrite the current cell.

Temporal & Environment

  • breathe : Suspend thread execution for exactly 1000ms.
  • clear : Clear the terminal screen using ANSI escapes.

QoL & Architecture Power Features

  • passion : Add 10 to the current cell.
  • heartbreak : Subtract 10 from the current cell.
  • forget : Instantly set the current cell to 0.
  • confess : Output the raw integer value of the cell natively.
  • destiny : Absolute pointer dereferencing (teleports the pointer to the address equal to the current cell's value).
  • wonder : Injects hardware entropy (rand() % 256) into the current cell.
  • fade : Gracefully terminate the process (exit(0)).

Implementations

The official reference implementation, ivoryc, is a single-pass Ahead-of-Time (AOT) transpiler written in C++. Rather than interpreting the code, it lexes the source into a temporary C++ Intermediate Representation (IR), and invokes the local system's g++ toolchain to compile an optimized native binary (ELF/PE).

Examples

Hello, World!

Due to the bulk arithmetic opcodes (passion and heartbreak), Ivory source code is significantly more compact than standard Brainfuck. An optimized "Hello, World!" program is as follows:

passion passion passion passion passion passion passion
adore adore whisper passion passion adore adore adore
adore adore adore adore adore adore whisper adore
adore adore adore adore adore adore whisper whisper
adore adore adore whisper forget passion passion passion
passion adore adore adore adore whisper heartbreak miss
miss whisper passion passion passion passion passion adore
adore adore adore adore whisper passion passion adore
adore adore adore whisper adore adore adore whisper
miss miss miss miss miss miss whisper miss
miss miss miss miss miss miss miss whisper
forget passion passion passion adore adore adore whisper
fade

Cat Program

A standard `cat` program that echoes user input back to the terminal until a null byte is encountered. This demonstrates the `promise` and `always` loop structures alongside the `listen` and `whisper` I/O opcodes.

listen
promise
    whisper
    listen
always
fade

The Fibonacci Sequence

Because Ivory includes the confess opcode, it bypasses the need for complex ASCII-conversion algorithms when doing raw mathematics. The following program calculates the Fibonacci sequence up to 233 (the 8-bit integer limit of the tape), printing each term natively with a dramatic one-second breathe pause between calculations.

clear

passion adore adore adore adore
hold forget
hold forget adore
hold forget
release release release

promise
    hold confess
    breathe

    promise
        miss
        hold hold adore
        release release
    always

    hold
    promise
        miss
        release adore
        hold hold adore
        release
    always

    hold
    promise
        miss
        release adore
        hold
    always

    release release release
    miss
always
fade