"Haifu" is Mandarin for "sea duck". It is also be Japanese for something - I believe "assortment" or "allotment" or a similar concept.

It is also the name of a programming language I am developing to address the lack of Eastern philosophy in the current set of commonly used languages such as C and Java. The meanings of "haifu" all describe essential qualities of the language.

Note: The specification for Haifu is not quite complete. I don't think it's quite enough as it stands to be a fully-featured programming language. It's not likely I'll ever return to finish it off, however.

Design Principles

Language Concepts

Haiku Structure

Haifu code consists of normal English words, arranged into haiku of three lines each. The first line of each haiku contains 5 syllables, the second line 7 syllables, and the third line 5 syllables. Any other arrangement is a syntax error. A program may contain any number of haiku, arranged sequentially. Words may not be broken across lines or haiku by hyphenation, unless the word is normally hyphenated.

Tao-ian Values

The restrictive Western notions of true and false are not used. Instead, Haifu programmers must be aware of Yin and Yang. The programmer must concern him or herself with balancing Yin and Yang values throughout the program to achieve balance, since without balance the program will not run. Of course, if the programmer is one with the Tao balance will come effortlessly.

Even numbers have Yin quality, while odd numbers have Yang quality. Floating point numbers have the quality of the number they are "reaching for" (i.e. they are treated as if rounded away from zero; 1.2 is Yin, -2.3 is Yang).

The Five Elements

Data values are associated with one of the five elements: Earth, Fire, Water, Wood, and Metal. Each element relates to the other four in different ways:

Ascension to the Celestial Bureaucracy

The Celestial Bureaucracy is a strictly ordered hierarchy of positions into which data values, variables and operators may be placed. These items are placed on the bottom-most rung of the Bureaucracy, and may only approach Heaven by the placing of further items below them. Items may also be removed from the Bureaucracy, from any rung. When items are removed, all items above them lose influence and thus descend away from Heaven. [Unenlightened Western programmers may see some similarities to a stack structure, but such observations are narrow-minded and misleading, as the Celestial Bureaucracy operates in the spiritual realm, unlike materialistic Western data structures.]

When a Haifu program is executed, all non-comment words and punctuation marks are placed in order into the Celestial Bureaucracy. Hyphenated words are treated as a single word. When all the haiku have been thus processed, the Bureaucracy contains all words of the code, with the first word nearest Heaven and the last word furthest away. The Celestial Bureaucrat (language interpreter) then processes the words beginning at the bottom rung, ascending one rung at a time, until the Bureaucrat reaches Heaven (i.e. is "above" all the words in the Bureaucracy), at which point the program terminates. The Celestial Bureaucrat does not occupy positions in the Bureaucracy, but merely looks at the words.

The Celestial Bureaucrat has a Delegate to help him. The Delegate also begins looking at the bottom rung of the Bureaucracy, but only ascends or descends on the direct orders of the Celestial Bureaucrat. Additionally, no matter what orders are given to the Delegate, he may never rise to a position higher than the Celestial Bureaucrat - if such an order is given, the Delegate merely rises to the same level as the Celestial Bureaucrat.

Syntax Elements

Haifu is not case-sensitive. Words may be capitalised as desired for literary effect.

Data Values

Haifu supports only numerical data, though in I/O they may be interpreted in different ways. In particular, character data are interpreted as Unicode values (to allow operations on Asian characters, though this also works for Western characters). Both integers and floating point numbers are supported, although there is no distinction between them.

Integer literals may be specified by writing the number in English, in either cardinal (one, two, three) or ordinal (first, second, third) form. Additionally, common synonyms for numbers are accepted: "no", "none" for zero, "a", "an" for one, "couple" for two, "dozen" for twelve, "century" for one-hundred, etc. A literal which forms a single number must be hyphenated together, otherwise it will be treated as two numbers: "two hundred" is 2 followed by 100, "two-hundred" is 200. Numbers, especially long ones, may be hyphenated across lines and/or haiku to maintain proper haiku structure. The size of integers specifiable is governed by the artistic problems inherent in filling an entire haiku with just a number.

Random numbers may be generated using words such as "some", "few", "many", etc - which evaluate to suitable random integers whenever encountered by the Celestial Bureaucrat or Delegate.

Floating point literals may not be specified and can only be generated by operating on integers. If a floating point number is required to be interpreted as an integer (for Unicode output, for example), it is treated as the number it strives for (see the Yin/Yang section).

All number literals are reserved words in Haifu. All number literals are initially of Earth elemental quality.

If the Celestial Bureaucrat encounters a numeric literal, it is beneath his dignity and he ignores it and ascends to the next rung of the Bureaucracy.


Any non-reserved word which possesses the fundamental qualities of one of the five elements and is not a vulgar word may be used as a variable name. Vulgarities are forbidden because they should not be used in delicate artistry such as Haifu code. The variable maintains the qualities of that element until changed by an operator. Examples of variable names in each element: Variable names may be referred to by both singular and plural forms - "tree" and "trees" refer to the same variable. Any word which is not clearly associated with a particular element is considered to have Earth quality, though it is considered bad programming practice to rely on this.

Variables may contain a sequence of orders remembered by the Celestial Bureaucrat. The remembering of orders is discussed under "Punctuation" below.

Note that when a variable name is placed into the Bureaucracy it is the variable itself, not just its value. A variable may fill multiple roles in the Bureaucracy, and thus appear in it many times at different levels of enlightenment. If the value or elemental nature of the variable changes, the change applies to all roles in which the variable finds itself. This may confuse unenlightened Western programmers, but those in harmony with the Tao realise there can be no other way and bend as the willow to the requirements.

If the Celestial Bureaucrat encounters a variable, it performs the sequence of orders it has remembered as the definition of that variable. If the variable has not yet been defined, the Bureaucrat does nothing and ascends to the next rung of the Bureaucracy.


Punctuation marks enable the definition of commands. When the Celestial Bureaucrat encounters a punctuation mark it treats the next word as a variable name and the following sequence of orders as a definition of that variable. As it ascends through the orders it does not process them, but merely remembers the sequence, until it reaches either another copy of the command name, or any punctuation mark. That completes the definition of the variable, and the Celestial Bureaucrat then continues ascending the Bureaucracy, processing orders as normal. Variable names may be redefined later.


The following reserved words are operators in Haifu. When the Celestial Bureaucrat encounters them, they cause certain operations to be performed, often by the Delegate. Words which perform the same operation are listed separated by /. Note that tense, plurality and conjugation variations are treated as the same word, so "destroys", "destroying", "destroyed" and "destruction" are identical to "destroy".

If any order specifies an operation which makes no sense, the Bureaucrat ignores it and ascends to the next rung of the Celestial Bureaucracy.

Celestial Bureaucrat Control

Delegate Control

I/O Control

Elemental Control

Numeric Control


Comments may be inserted between any words in the code, and are delimited by matching pairs of commas. Words in comments count towards syllables on each line. A comment at the end of a program, after which there is no more code, does not need a terminating comma delimiter. The words of a comment and the commas are not placed into the Celestial Bureaucracy.

As in all good programming practice, comments are used to elucidate sections of code, provide extra syllables for syntactic integrity, and make poignant observations on the nature of life and the ephemeral qualities of beauty. Comments may span haiku, and may be several haiku long if the programmer has something particularly insightful to say about the code or the universe in general.

Home | Esoteric Programming Languages
Last Updated: