DEV Community

Michael Tharrington
Michael Tharrington Subscriber

Posted on

Can code be poetic?

Disclosure: I'm not a software developer and I don't really have an opinion on this. I'm just curious what others think. πŸ’‘

Jimmy Fallon wearing all black and a beret and snapping his fingers. He looks like a stereotypical poet.

Have you ever come across or created any code that you felt was poetic?

I've heard folks describe code as being written elegantly. I've also heard folks talk about leaving good guidance via comments in their code. But, I'm curious if anybody has seen anybody take these elements and try to make something creative or artistic out of it β€” not what the code creates, but the code itself.

What do you think? Can code be poetic or artistic in a writerly sense? Do you have any examples of code like this that you'd like to share?

Top comments (35)

Collapse
 
jmfayard profile image
Jean-Michel πŸ•΅πŸ»β€β™‚οΈ Fayard • Edited

can code be poetic?

#!/usr/bin/perl 

APPEAL: 

listen (please, please); 

open yourself, wide; 
    join (you, me), 
    connect (us,together), 

tell me. 

do something if distressed; 

    @dawn, dance; 
    @evening, sing; 
    read (books,$poems,stories) until peaceful; 
    study if able; 

    write me if-you-please; 

sort your feelings, reset goals, seek (friends, family, anyone); 

            do*not*die (like this) 
            if sin abounds; 

keys (hidden), open (locks, doors), tell secrets;

do not, I-beg-you, close them, yet.

                    accept (yourself, changes), 
                    bind (grief, despair); 

require truth, goodness if-you-will, each moment; 

select (always), length(of-days) 

# listen (a perl poem) 
# Sharon Hopkins 
# rev. June 19, 1995 docstore.mik.ua/orelly/perl/prog3/ch27_02.htm
Enter fullscreen mode Exit fullscreen mode
Collapse
 
michaeltharrington profile image
Michael Tharrington

Loving this! I'm trying my best to follow and I think I got it. πŸ˜€

By the way, the whole impetus for this post came about because of our conversation here:

So simple yet profound

πŸ‡¨πŸ‡Ί Un jardinero de amor, planta una flor y se va.
πŸ‡¨πŸ‡Ί Otro viene y la cultiva, ΒΏde cuΓ‘l de los dos serΓ‘?
πŸ‡¬πŸ‡§ A gardener of love, plants a flower and leaves
πŸ‡¬πŸ‡§ Another comes and cultivates it, which of the two will it be?

pure poetry

Collapse
 
abhinav1217 profile image
Abhinav Kulshreshtha

Is this from perlmonk website? This is quite poetic.

Collapse
 
jmfayard profile image
Jean-Michel πŸ•΅πŸ»β€β™‚οΈ Fayard

I don't remember where I've seen it first, I have done Perl programming almost 20 years ago :P

Collapse
 
ruslanastratov profile image
Ruslan Astratov

Wow!

Collapse
 
nombrekeff profile image
Keff

That's beautiful ❀️

Collapse
 
bobbyiliev profile image
Bobby Iliev

Yes! Even Shakespeare agrees:

Shakespeare: An ssl error has occured and a secure connection to the server cannot be made

Collapse
 
michaeltharrington profile image
Michael Tharrington

Haha, well I'm not gonna argue with Shakespeare!

Collapse
 
abhinav1217 profile image
Abhinav Kulshreshtha

He has his own programming language called Shakespeare

Collapse
 
erhant profile image
Erhan Tezcan

There is an esoteric language called Rockstar, a Turing-complete language where the code is like a song lyrics. Here is how FizzBuzz looks like:

 Midnight takes your heart and your soul
 While your heart is as high as your soul
 Put your heart without your soul into your heart

 Give back your heart


 Desire is a lovestruck ladykiller
 My world is nothing 
 Fire is ice
 Hate is water
 Until my world is Desire,
 Build my world up
 If Midnight taking my world, Fire is nothing and Midnight taking my world, Hate is nothing
 Shout "FizzBuzz!"
 Take it to the top

 If Midnight taking my world, Fire is nothing
 Shout "Fizz!"
 Take it to the top

 If Midnight taking my world, Hate is nothing
 Say "Buzz!"
 Take it to the top

 Whisper my world
Enter fullscreen mode Exit fullscreen mode

I guess we can say that it is somehow poetic?

Collapse
 
michaeltharrington profile image
Michael Tharrington

Wow! I'd never heard of this before. It's wild looking!

So many great lines in there. "Whisper my world" sounds quite nice. 😁

Collapse
 
link2twenty profile image
Andrew Bone

The experiences one creates with code can be poetic but as words without intent can seldom be called poetry nor can code without form.

Painting is poetry that is seen rather than felt.
Leonardo da Vinci

I tried to make that sound arty, did it work πŸ˜‰?

Collapse
 
michaeltharrington profile image
Michael Tharrington

lol, mission accomplished. It did indeed sound arty and the content was enlightening too. So, code without form isn't gonna be poetic code. Gotcha!

One thing I didn't disclose above is that I studied Creative Writing in university (my focus was fiction not poetry, but I had my fair share of classes on poetry) and something that I heard pretty regularly was that if you know the rules, you can break them. There were some pretty interesting pieces where someone would intentionally break the rules for different reasons β€” to make their work stand out OR because they felt it worked better OR maybe even to take a stand against rules that they felt were confining them. I remember learning about prose poetry at the same time I was learning about short, short stories (generally a page long) and I thought, ughhhh, this isn't poetry, this is just another short story, haha! In the end, I don't think it mattered to the writers β€” they just thought of it as writing.

Anyway, not sure where I'm going with this, besides just saying that I agree with you! I like that you included "intent" in your explanation because I think that is key to what I was saying in the paragraph above. If your intent is to break the form, and you have thoughtful reasons for breaking it the way in which you did, then you can still probably achieve something poetic.

Collapse
 
cicirello profile image
Vincent A. Cicirello

Ada Lovelace, mathematician and widely considered first programmer, daughter of the poet Lord Byron, would most certainly answer your question with a yes. Her mother pushed her into math and science to try to distance her from her father. And Ada once wrote to her mother as a response something like: "If you can’t give me poetry, can’t you give me poetical science?"

Collapse
 
michaeltharrington profile image
Michael Tharrington

Wow! Thanks for sharing this. I had no idea that she was related to Lord Byron. That is pretty incredible. I just briefly looked it up and it sounds like he was a dirtbag of a dad! Still, super interesting stuff. I also love the quote you shared here. πŸ‘

Collapse
 
cicirello profile image
Vincent A. Cicirello

She used the word science in the quote, but with all the work she did programming Babbage's Analytical Engine, she almost certainly meant that. It makes me wonder what she would have accomplished if she had access to today's computers.

The link you shared has some interesting things in it. I didn't know that despite how bad a person her father was, and that she didn't know him, that she requested to be buried with him. I also hadn't heard the speculation that her programs for the Analytical Engine possibly included horse race gambling predictions.

Thread Thread
 
michaeltharrington profile image
Michael Tharrington

Haha, the horse race gambling predictions is so out there and seriously cracks me up because we constantly fight spammers who post gambling content on DEV! Please tell me Ada wouldn't have been a casino spammer... πŸ˜† (Kidding, of course!)

But yeah, there was another Ada Lovelace + horse fact in that article that was also super amusing:

  1. At the age of 12, Lovelace conceptualized a flying machine.

After studying the anatomy of birds and the suitability of various materials, the young girl illustrated plans to construct a winged flying apparatus before moving on to think about powered flight. β€œI have got a scheme,” she wrote to her mother, β€œto make a thing in the form of a horse with a steamengine in the inside so contrived as to move an immense pair of wings, fixed on the outside of the horse, in such a manner as to carry it up into the air while a person sits on its back.”

It sounds bizarre and so impractical, but I'm in love with this idea, haha!

Thread Thread
 
cicirello profile image
Vincent A. Cicirello

The steam engine powered winged horse is awesomely crazy (in a good way), and perhaps an example of what she had in mind by poetical science. Although there are videos on youtube of nearly as bizarre contraptions people actually built in early 1900s in early flying attempts.

Collapse
 
dantiel profile image
dantiel

code is anti-poetic, so when you write code, you basically write an anti-poem, especially when you're working for the industry, you're anti-poetic, that doesn't mean its non-poetic, because writing code is a creative habit, just as writing a poem is, because existence is non-poetic, and non-existence is poetic, there isnt anything less poetic than the poet himself, but in the aetherical battle of a sleep-deprived individual against the frivolous capitalist system, the machine-leviathan, taming the dragon, befriending him, making him compliant and his endeavor fruitful, his work may feel poetic, but for the reality it is too late, now that he has become a robot. I would also say any poem is an anti-poem, because it means reinventing language and its use, therefore id say there are ways to write poetic code, like an elegant solution is always poetic in sense that it counts for programs as well as for a dance. furthermore a poem isnt more poetic if it is written in another language, it must be like music, always in the right language and tone, that means if you write a poem in code-style it is like noise-music, words are words, vibration is vibration, a rose is a rose.
in summary to clear some things up: written words are subset of poetry, and code is a subset of written words, but those are only the levers of the machine. flattering poems are a way to try program and failsafe the heart of human. but a heart must be free, and a robot must do its duty.

Collapse
 
michaeltharrington profile image
Michael Tharrington

This is a really deep take! I'm probably gonna need to read through it a few times to fully understand, but I think I get the gist and it's super interesting.

You mentioned "especially when you're working for the industry" and I think what you're getting at here is that when you're coding for someone to make money, you're doing a job and that feels in opposition to writing poetry which is typically thought of more as a creative expression that was made for the sake of the expression (and not to bring in cash).

But, if someone is coding for themselves, exploring methods, and creating more for the sake of creation and self expression than for dollars, then that would be more in line with writing poetry.

Collapse
 
dantiel profile image
dantiel

as a human being I am in-between AI, robotics and nature with its consummation needs, I code therefore I am, which is untrue because more true in robotic language will be, I am coded, therefore I am.
If I can write an AI that writes poems, to get dollars for it, then both the code of this program and its return value will be poems, but it will be a very terrible one to read.
there must be a recipient which probably must have a soul or a conscious. so if you think that a machine has a soul or conscious, every bit of zero and one will be part of a breathtaking poem.... but coding and language is related because it means compression of information on a higher level of abstraction, by AI machines may replace our brains but not our deepest inside. when I write a poem, I ask my stomach about his opinion, if he gulps, then it is good, false otherwise.

Collapse
 
canolcer profile image
Can Olcer

I think code can be beautiful and satisfying for its own sake. I know that nowadays there's a lot of focus on shipping quickly, but I take a lot of joy in writing beautiful code - not because it will make the product better for users, but because it makes me happy.

That's also one of the aspects I love about Ruby and Ruby on Rails - they give a damn about developer happiness. You can find some good examples in the Rails Doctrine.

Collapse
 
polterguy profile image
Thomas Hansen

I have a t-shirt that says; "Code is my poetry". Yes, definitely code can be poetry ... :)

Collapse
 
michaeltharrington profile image
Michael Tharrington

Haha, that's a great t-shirt! πŸ˜€

That would be a pretty nice addition to the Forem shop... just sayin. πŸ˜…

Collapse
 
jonrandy profile image
Jon Randy πŸŽ–οΈ • Edited

A lot of the examples here are either code written to read like English language poetry, or mention programs that output something poetic. I'm not sure this was what the OP was getting at...

I do believe code can be poetic. One sense of 'poetic' is:

having an imaginative or sensitively emotional style of expression.

It's certainly possible to use language constructs in imaginative and creative ways - often resulting in code that is elegant and unique, sometimes reinterpreting or shining an entirely different light on code syntax and grammar.

Code like this could certainly be considered poetic IMO. All art is subjective

Collapse
 
michaeltharrington profile image
Michael Tharrington

I really like that take, Jon!

Definitely open to hearing everybody's different interpretations and find all of this interesting, but you're right that I was thinking along the lines of writing code that is imaginative or creative in some way and less related to writing in English.

Collapse
 
abhinav1217 profile image
Abhinav Kulshreshtha • Edited

There is an esoteric programming language called Shakespeare In which programs are written as a play.

And then there is a poetic language

Also, you can write poetic code in perl or ruby, There is a community website called perlmonk where people frequently submit piece of code written in a poem. There are few other eso langs which produce quite poetic code, like rockstar, or even Ook! can be quite rhyming.