How did I end up writing poems about algorithms and data structures?

I was thinking about looking for a new job and so I was studying computer science books, going over all the concepts that I had never studied formally, kind of floating between reading Algorithms to Live By, Sedgwick’s textbook, and some study guides.

I was struck by the way that algorithms were presented in these books. The two most common types of algorithms covered in this kind of introductory material are sorting and searching algorithms. I started to think about how these two categories – putting items in order and finding something in a collection – reflected basic human impulses – order and desire. To sort is to categorize, to create logical relations, to make connections. To search is to look for the thing you need, perhaps after having sorted, perhaps having not.

To think about algorithms as reflective of human impulses is to see them in a new light. While the performance of an algorithm – its efficiency and rate of success – are something that can be measured objectively, there’s also something deeply human about sorting and searching through representations and other forms of data.

What if we thought about algorithms as expressions of human desire? I looked at the implementation of mergesort that I had been studying. The first line of the code is the base case – an early return in the case that the algorithm had completed its job.

if (array.length < 2) return array

If there are less than two items in the collection, return it. But what if we expressed this line from the point of view of the algorithm itself. What would the algorithm say to its input?

If you are alone return

The line came to me as I was on a run and I felt like I had to continue to translate the algorithm into plain speech. What if each line of code could be translated into pseudocode into a way that expressed the human desire behind the algorithm in poetic terms. The method I would land on would be something between allegory and impressionism. It was allegorical in the sense that I was trying to write poems that followed the homology of the algorithm – changing out the content for poetic images. And it was impressionistic in the sense that sometimes I just inserted my own ideas into the poems, things that occurred to me as I thought about the algorithm.

When I started writing the poems, it occurred to me that I was doing a thing that most people would think is strange, perhaps objectionable or just boring. But I became so engrossed in the project, that I eventually forgot that perspective. As I wrote more and more poems, I lost the ability to think “How would the average poetry reader think about this poem?” because I was translating between these unconnected domains.

Retrospectively, there is doubtless something monstrous about the project. It feels important to clarify that I never had the intention of romantaicizing code. Vikram Chandra has this moment in Geek Sublime where he mocks the idea of the “poet-programmer.” And I think that’s fair, especially in the context of his nuanced discussion of aesthetics. But I remain convinced that there’s something interesting in the world of algorithms that can be brought out by poetry. If geology or astrophysics or microbiology can be the subject of poetry, why not algorithms?


I agree with Chandra that the idea of the “poet-programmer” is ridiculous and many software engineers have an impoverished view of literature. But if one of the deficits of the programmer is that they think they know everything about art, we also have to admit that many humanists have little respect for the complexities and depths of code.

When Chandra says that the “the culture of art-making may be in fact foreign to them,” I recognize a resistance to the imperialism of the tech industry, its easy cooptation of the language of art and culture. But I also worry that there is an elitism or a kind of gatekeeping in depicting programmers as philistines who can’t appreciate art. Ultimately, I think that both domains would do well to learn from one another.