Code poetry (are you experienced with Fortran words?)

I have recently discovered what is code poetry on this blog presenting the new book ./code --poetry by Daniel Holden and Chris Kerr.

Code poetry is built on a simple premise: it is a single text that reads as poetry and executes as code.

The book uses many languages but I don’t know if Fortran is included as I did not find the table of contents of the book. So I tried to play with this concept as I think it can be interesting to explore the particularities of Fortran in this context.

With this first attempt I have obtained an executable program that can be read as a text, although it is not totally satisfying as it prints nothing really pretty or poetic… But I am sure people here could improve it or write a more interesting one!

! O Fortranner,
program with_your_mind
  !, so
        logical :: a = .true. !computer!

such_a_task: do it = 1, 1000000000 ; fast  = &
    cos(real(it)) !is
        if (a) print *, "occurs in ", it
            end do such_a_task !again without torment
                end program with_your_mind !with eternal delight, Fortranner!

A few remarks:

  • One advantage of Fortran is that indentation is free, like in modern poetry. It can be useful to ease the text reading, or to sculpt it with a specific geometrical shape.
  • I must admit it is the first time in my career I use implicit typing in Fortran and it is really useful for code poetry (no bashing please :grimacing: !). Here I included logical in my text, but I was happy to avoid declaring it and fast.
  • I used some phonetic tricks: cos must be pronounced 'cause and end must be pronounced and. This last one is very useful in Fortran as all blocks of instructions are terminated with an end something: you can use it to obtain a kind of refrain. Labels can also help for this.
  • Comments are of course very useful for words outside of Fortran vocabulary.
  • With ; and & you can manage line feed more freely.
  • And probably the fact that there is no reserved word in Fortran can help.

Of course, torturing Shakespeare’s language (sorry…) is easier but probably it is also possible to write something in European languages sharing roots with English. For example in English the verb:

!to
	program

would become in Molière’s language (don’t read the space):

program mer

In other languages, it may be much harder but maybe not impossible in some of them (and implicit typing could save the situation… :sweat_smile:). After all, constraints are known to stimulate creativity. In classical poetry, we have for example rhymes, forms, metrics…

Don’t hesitate to hack the vocabulary of your favorite poets or singers, whether it’s William Blake or Jim Morrison, if it helps opening the do.or.s of perception. I think it can be interesting to explore in this post the features of Fortran that could be useful in code poetry. And it would be great to obtain some truly poetic programs writing or drawing something poetic or artistic in the terminal, and maybe using an artistic typography.

3 Likes

… and I thought I would never wish the program statement was not imperative. It restricts my choices for the beginning of the Fortran poem. :laughing:
But wait, it must be valid code that runs as-is? Can’t we just do “poetry” with chunks of (valid) code that’s not necessarily the whole program?

The end statement is imperative, but we can accept that it just marks the end of any poem, like at the end of a movie… Here I decided to take advantage of program to talk about coding…

As it is absolutely modern poetry, I would say: feel free to define your own rules… See for example these codes:
https://code-poetry.com/compound_eye
https://code-poetry.com/chernobyl
https://code-poetry.com/alone_in_kyoto
https://code-poetry.com/submarine
https://code-poetry.com/flocking

This one is interesting typographically and graphically:
https://code-poetry.com/code_violation

But I think my favorite one is:
https://code-poetry.com/water

I am thinking about buying that book, as a book mixing code, poetry, graphism and typography is definitely an interesting object to put in my library…

I did not answer, but yes, it must compile and run, and ideally do some ASCII art in the terminal (contrary to mine)…
On the site above, you can read the code on the left and see the execution on the right.