Article continues after the ad.

Hey, fellow writers and tech enthusiasts! Generative AI is all the rage right now, so I thought, why not create one of my own! Well, not really Gen AI, but at least a simple function that's playful and fun! I'm stoked to share with you my latest creative experiment: bringing poetry to life with code and digital tools.

As a poet, I've always been fascinated by the way words can be manipulated and transformed to create something new and beautiful. And what better way to do that than with code? I mean, think about it: code is like a magic spellbook that can take your words and turn them into something entirely new.

I've been experimenting with using code to generate poetry, and it's been a total game-changer. By combining algorithms with my own poetic ideas, I've created some truly unique and stunning pieces of art.

Here's my poem "Echoes in the Code":

function randomChoice(arr) {
return arr[Math.floor(Math.random() * arr.length)];
}

const openings = [
"In the whispers of the wind,",
"A silence unfolds,",
"A memory stirs,",
"Beneath the hum of dusk,",
"Somewhere in the forgotten light,"
];

const verbs = ["drifts", "lingers", "fades", "blooms", "unfolds"];
const subjects = ["A gaze", "A dream", "A whisper", "The shadow", "A random memory"];
const closings = [
"like a half-remembered song.",
"written in binary stars.",
"falling between breaths.",
"with an unfiltered thought.",
"neverending, unconscious, unforgettable."
];

console.log(randomChoice(openings));

for (let i = 0; i < 6; i++) {
const chance = Math.random();
if (chance < 0.6) {
const line = `${randomChoice(subjects)} ${randomChoice(verbs)}, ${randomChoice(closings)}`;
console.log(line);
}
}

In this short poem, the console becomes a field of wind-blown thoughts. Every loop iteration is a poetic memory, and only some catch the floating fragments -

"silent""gaze""dream""echo", like thoughts too soft to stay.

The resulting output is like a digital echo chamber, where the words and ideas blend together in a beautiful, surreal way. The randomness mirrors how memory surfaces without warning.

Every time you run it in the console, you get a new poem, constructed from semi-random poetic fragments, about love, remembering, missing or heartbreak - You can interpret it differently each time.

here's how it works:

  1. Open with an ambient or emotional scene.
  2. Generate 0–6 poetic lines depending on random chance.
  3. Use verbs, metaphors, and sensory language to mimic the style of modern minimalist poetry.

Here are 2 examples that I generated from this:

In the whispers of the wind,
A dream drifts, like a half-remembered song.
A random memory lingers, neverending, unconscious, unforgettable.
A gaze drifts, falling between breaths.

And heres the other one:

A memory stirs,
A gaze drifts, like a half-remembered song.
A whisper blooms, with an unfiltered thought.
The shadow blooms, falling between breaths.
A random memory lingers, neverending, unconscious, unforgettable.

I know what you're thinking: "Zoe, this is all well and good, but what about the soul of poetry?" And to that, I say: "Ah, but that's where the magic happens!" Code and poetry aren't mutually exclusive; they're complementary, like yin and yang.

By using code to generate poetry, I'm not only creating something new and interesting; I'm also pushing the boundaries of what we consider "poetry" in the first place. It's like I'm taking all the possibilities of language and turning them into a digital artwork.

So, what do you think, friends? Are you ready to join me on this digital poetry experiment? Let's collaborate with code and bring poetry to life in ways we never thought possible! If you run it, let me know your own suggestions for improvement below!

#GenerativeAI #Poetry #CreativeCoding #TechArt #DigitalCreativity