Ku
Paradigm(s) | poetic, imperative, stack-based |
---|---|
Designed by | User:Shivani |
Created in | 2025 |
Memory system | stack-based |
Dimensions | one-dimensional |
Official interpreter | ku-lang |
File extension(s) | .ku |
Influenced by | Haiku Poetry (Japanese) |
Syntax style | haiku (5-7-5 syllables) |
Website | Website |
GitHub | GitHub repo |
NPM package | ku-lang on npm |
More documentation | Lore |
Sample program | he river is calm three plus three is flowing now echo river now |
Ku is a poetic one-dimensional esoteric programming language created in 2024 by User:Shivani where every program must be written in haiku format (5-7-5 syllables). Code combines natural language programming with strict syllable validation, featuring rhyme detection, palindrome word processing, and haiku fusion while maintaining the beauty of traditional Japanese poetry.
Language overview
A Ku program consists of haikus arranged sequentially, where each haiku must follow the strict 5-7-5 syllable structure. The program is processed line by line, with each haiku representing a complete instruction block. The interpreter validates syllable counts and processes natural language commands within the poetic constraints.
Execution proceeds through a simple linear flow, reading each haiku from top to bottom. The interpreter maintains a memory system for variables and a stack for temporary calculations. Each haiku is parsed for its semantic meaning while simultaneously validating its poetic structure. If a haiku fails syllable validation, execution halts with an error message indicating the specific line and expected syllable count.
Ku programs use English words as variable names and do math by writing numbers as words. The language has special features that detect when lines rhyme (which makes variable values twice as big) and when words are palindromes (which flips the haiku backwards). Programs can make decisions and repeat actions using special haiku commands. Here's an example of how to store a value in a variable:
the moon remembers five plus two in the night sky echo moon bright now
History
The history of this language is not so old and not so big.
Until recently, I never thought I’d make my own esolang—because, well, it’s not exactly a normal thing to do. I’ve built some things from scratch before, but this one came to life as part of a YSWS challenge at Hack Club!
I am happy that I did this!
More info is on Ku's Website
Struggles during development written on this Doc
Etymology
The name ku comes from the Japanese word “句” (ku), which means “verse” or “phrase” and is the term used for each line in a traditional haiku poem.
This reflects the language’s core requirement that every program must be written in the form of a haiku, following the 5-7-5 syllable structure. The name was chosen to emphasize the poetic and artistic nature of the language, blending the realms of programming and poetry.
Examples
Variable/Operators assignment and print
the moon remembers five plus two in the night sky echo moon bright now
Assigns the value 7 to moon
and prints it.
Function definition
summon the sun now the light remembers the day three plus four is bright
Defines a function called the sun
that stores and processes values.
Function call
call the sun now the light remembers five plus five
Calls the previously defined the sun
function with new values.
Conditional execution (if statement)
the stars remember five plus two in the dark night echo stars shine bright the sum remember one plus one in the bright sky echo sum again if stars is greater than three this is a haiku line this is another line the sum remember one plus one in the bright sky echo sum again
Checks if stars
is greater than 3; if true, executes the next haiku.
If statement (false condition)
the stars remember five plus two in the night sky echo stars again the sum remember one plus one in the bright sky echo sum again if stars is greater than ten this is a haiku line this is another line
Checks if stars
is greater than 10; since it is not, the next haiku is skipped.
If statement (variable not set)
if moon is greater the stars remember one plus one
Attempts to check a variable that is not set, which triggers an error or default behavior.
Palindrome effect
the sun remembers one plus two plus two civic echo civic now
If a palindrome word is detected, the haiku is reversed before output.
Regular haiku (assignment and echo)
the river is calm three plus three is flowing now echo river now
Assigns 6 to river
and prints it; can trigger rhyme or palindrome effects.
Rhyme effect (doubles value if last words rhyme)
the stars remember five plus two in the dark night echo stars shine bright
If the last words of lines 2 and 3 rhyme ("door" and "more"), the value of score
is doubled before printing.
Loop (countdown)
count from three to one numbers disappear each time until none remain
Counts down from three to one, removing a number each time and printing the result.
Function fusion
summon magic now civic flows at dawn today birds fly in the sky call the magic now kayak glides on lake today ripples in the blue
When a function is called in Ku-Lang, the interpreter can "✨ fuse" the summoned function's haiku with the calling haiku to create a new, combined haiku. If either haiku contains a palindrome word (like "civic" or "kayak"), the fused haiku is reversed before output, adding a poetic twist to the program's behavior.
Installation
Install globally
npm install -g ku-lang
Note: On macOS/Linux, you may need to use sudo npm install -g ku-lang
if you get permission errors.
Limitations
English only: Ku-Lang currently only supports English words for both code and variable names. Programs written in other languages will not be recognized as valid.
Strict haiku structure: Every program must follow the 5-7-5 syllable haiku format. Any deviation will result in an error.
Limited number words: Arithmetic is only supported for numbers one through ten, using English words.
No floating point or negative numbers: Only positive integers (one to ten) are supported in expressions.
No nested functions: Function definitions (“summon”) cannot be nested within other functions.
No advanced data types: Only basic variables and numbers are supported; there are no arrays, objects, or complex data structures.
Word validation: Only words found in the included English word list are considered valid; uncommon or invented words may cause errors.
Limited error handling: While error messages are descriptive, the interpreter may not catch every possible edge case gracefully.
No Unicode or emoji support: Only standard ASCII English words are supported for code and variable names.
Packages Used
Ku-Lang makes use of the following open-source packages:
syllable: Counts the number of syllables in each line to enforce the 5-7-5 haiku structure.
word-list: Provides a comprehensive list of valid English words for word validation.
nodemon: (Development only) Automatically restarts the interpreter during development.
Note: The current interpreter uses custom logic for rhyme detection and does not directly use any packages for it.