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.

Sprh

From Esolang
Jump to navigation Jump to search

SPRH is an esoteric programming language designed by LargeHardTech in 2025. The name stands for **Slow** (interpreted execution, feeling each step of change), **Poor Readability** (poor code readability, challenging the mind), and **Hard** (hard to program, implementing complex logic with minimal commands). It is inspired by 2D Turing machine models and aims to be a pedagogical tool for understanding low-level computational concepts. Unlike many esolangs that focus on minimalism, SPRH provides a moderately rich set of features, including a 2D memory grid, a single-byte variable register, a byte stack, arithmetic and bitwise operations, conditional and unconditional jumps, as well as console/file I/O. The language can either be interpreted directly or compiled to C++ for native execution.

Memory model

SPRH provides a **1024×1024 grid of bytes** as its primary memory, accessible via X and Y pointers which can be moved using directional commands. Attempting to move outside the grid bounds results in an error. In addition to the grid, the language features:

  • **A single-byte variable**: An independent register that can be used for arithmetic operations and assignments with the current grid cell.
  • **A byte stack**: Supports push, pop, swap, clear, and depth query operations.

Instructions

Hex parameters (1–F) are case-insensitive.

Pointer movement
Instruction Parameter Description
U / D / L / R 1–F (hex) Move up/down/left/right n steps
Arithmetic
Instruction Description
+ / - / * / / n Add/subtract/multiply/divide current cell by immediate value
++ Set current cell to 255
-- Set current cell to 0
= c Write the ASCII value of character c to current cell
Input/Output
Instruction Description
Pc Output current cell as a character
Pi Output current cell as an integer
I op Read a character from console, combine with current cell using specified operation
I= / Iw Read a character from console and write directly to current cell
F op Read a byte sequentially from input.spri, combine with current cell using specified operation
Fc Append current cell as character to output.spro
Fi Append current cell as integer to output.spro
Variable operations
Instruction Description
V= Copy current cell to variable
Vw Write variable to current cell
V+ / V- / V* / V/ Perform arithmetic between variable and current cell, store result in variable
Stack operations
Instruction Description
S+ Push current cell to stack
S- Pop stack to current cell (error if empty)
S= Swap top of stack with current cell (error if empty)
Sc Clear stack
Ss Write stack size (truncated to 8 bits) to current cell
Bitwise operations
Instruction Parameter Description
/ ^ / ~ / < / > u / d / l / r Perform bitwise AND/OR/XOR/NOT/SHIFT LEFT/SHIFT RIGHT with the neighboring cell in specified direction
Control flow
Instruction Parameter Description
> n 1–F (hex) Unconditional jump forward/backward by n instructions
[ / { / ( u / d / l / r If current cell equals/greater than/less than the neighboring cell in specified direction, jump to matching ] / } / )
Comments

Block comments are delimited with /* and */. Nesting is not supported.

Examples

Hello, World!

The following program prints "Hello, World!" by writing ASCII values directly and outputting each as a character:

=H Pc =e Pc =l Pc =l Pc =o Pc =, Pc =  Pc =W Pc =o Pc =r Pc =l Pc =d Pc =! Pc

Printing numbers from 0 to 50

This example demonstrates the use of relative movement and conditional jumps to implement a loop:

r1 =3 l1 /* Store ASCII '3' (51) at (1,0) as comparison base */ pi +1 [ r <3 /]

Computational class

SPRH is **Turing-complete**. The language features an unbounded (effectively 1024×1024) grid of bytes, conditional branching, and the ability to read and write arbitrary positions, providing sufficient capability to simulate a Turing machine. Its design draws explicit inspiration from 2D Turing machine models.

Implementations

The official implementation is written in C# and runs on .NET 8, providing both an **interpreter** (executing .sprh files directly) and a **compiler** (translating SPRH code to C++ for native compilation). The interpreter and compiler are distributed under the MIT License.

  • **Interpreter**: Directly executes SPRH source code. Suitable for debugging and teaching.
  • **Compiler**: Translates SPRH code to C++ source, which can then be compiled with any standard C++ compiler (GCC, Clang, MSVC) to produce native executables with near-native performance.

The implementation is **cross-platform**, supporting Windows, Linux, and macOS via .NET 8; compiled C++ programs are likewise cross-platform. Precompiled binaries are available from the [Releases](https://github.com/LargeHardTech/sprh/releases) page (e.g., sprh-win-x64.exe). The interpreter can also be built from source using the .NET 8 SDK.

External resources