On this page:
This page contains some examples of programs written in Poetic, as well as explanations as to how some of them work. As a secondary goal to functionality, each of these programs is meant to be as literarily interesting as possible.
Hello World!
the proverbial "unconsciousness"
i was already aware
i had understood fully
i
saw the devil
i was perfectly still
involuntarily i paused
there said i:
my
sheer consciousness
of certain given circumstances
i noticed
it's nothing
nothing
nothing any man wouldn't learn
a way of finding these
i know
not
nothing common or typical
and yet (somehow)
very little thought
will normally
resolve every contradiction
a foolish heart -> an eternal misfortune
This is the classic "Hello World" example. It is equivalent to the following brainf*** code:
While I do believe that this is the easiest version to understand, there are multiple ways to write this same program. Perhaps the really daring can try to find the shortest possible Hello World program in Poetic.
Cat Program
stranger, i confess i have longstanding problems i'm unprepared for
This program copies its input directly to output, and it is in the form of a haiku. Note that this displays a quirk with EOF in Poetic: upon reaching the end of the input stream, the IN command (8) no longer changes the value of the current byte.
Reverse Input
whenever i drink a beverage i'm always intoxicated .egnarts yllaeR i am inebriated
This program takes its input, lays out each character sequentially in memory, then outputs them in reverse. This is illustrated in the poem as the subject drinking so much that his perception of reality is literally reversed, with even his comments on his own situation being backwards.
ASCII Loop
love is a great mystery but i couldn't really explain it
Just for the sake of having another short, easy-to-understand example, this is a program that infinitely prints out every ASCII character. It is equivalent to the following brainf*** code:
The code +[>+.<] would work just the same, but some artistic liberties were exercised in order to create the most interesting poem. Also, because this program loops infinitely, the END command (0) is not needed.
Random Number
[ LIGHTNING ] *a flash!* *a zap!* *a flash!* *a zap!* a...Fourth of July? I am still electrified. Inside, I see a burst of flames... ...a fire... I am the source. LEAVE IMMEDIATELY BEHOLD, A HUGE METEOR CRASH IMMEDIATELY LEAVE I was frightened almost traumatized Have I heard hallucinations? Unspeakable evils? I say... I think no. No, their progression and advancement isn't a threat. I say... I think I am worse. I say... I think I'm no longer light. I'm shade. Inescapable dark. I am now sinister. I think I see little, except a dark, impenetrable cloud... No...no...never... ...I am purely-intentioned... I still try... ...try fighting longer.... Too late. I am truly with my people. Mischievous, devious... ...a dark disappearing animal. Gloomy night now is EVERYWHERE.
This program outputs a random number from 0 to 255, in decimal. This is meant to
demonstrate the RND command (9), which is represented here by the first word,
[ LIGHTNING ]. This program uses a custom routine to output the
current byte as a decimal number, dividing by 10 and taking the remainder until
the result is 0 to get all of the digits.