“The programmer, like the poet, works only slightly removed from pure thought-stuff. He builds his castles in the air, from air, creating by exertion of the imagination. Few media of creation are so flexible, so easy to polish and rework, so readily capable of realizing grand conceptual structures… Yet the program construct, unlike the poet’s words, is real in the sense that it moves and works, producing visible outputs separate from the construct itself. […] The magic of myth and legend has come true in our time. One types the correct incantation on a keyboard and a display screen comes to life, showing things that never were nor could be.” Fred Brooks
Many are those who look at programmers as to rigid, exact, and boring people who work with boring, rigid, and exact formulas that they type on their computers all day and all night long. Probably the same people look at poets as to incredibly creative individuals, with their heads in the clouds, and no regard to the real world.
Is programming like poetry? This hypothesis depends upon the willingness of the programmer to see his/her work as a creative process, to not look at the software creation as to a pure engineering discipline.
Science and mathematics lovers have seen this mysterious beauty in the configuration and symmetry of numbers that resembles the poet’s feel for the texture and word color or the painter’s native feel for harmony and sound of paint. Programmers and poets, have much in common. Poetry is not just a sequence of words chosen under a random pattern; this assemblage of words respects rhyme, rhythm and measure, all of which requires a native mathematical sense in creating the verses, even in today’s poetry that doesn’t honor as much the musicality of the rhyme. Under the same premise, programming is much more than writing sequences of code to make things move on the screen we’re looking at.
Good code is pure poetry, the elegant exposition of the perfect solution for a certain given problem. Bad code is an unbreakable nightmare, unfit in shape and confused in purpose.
Poetry depends upon a reference to a structure that is as formal as the constructs of a computer programming language, or of a piece of music. The sophisticated Shakespearean sonnets, the ballads, or the traditional forms have clear constraints of metre and sound and the talented poet has an impressive palette of techniques and tricks that are purely technical and go beyond the visible substance and matter of the poem. Free forms of poetry may seem that they’ve eluded the rules of form and metre, but are as dependent on the sound and rhythm of words and the reader’s expectations of their meaning, even in the absence of formal structure of the poems of E. E. Cummings who ignored conventional punctuation and syntax in favor of a dynamic use of language.
Valuable poetry is often the triumph of technique over substance. A poet like Cummings chose to write about traditional subjects such as love, childhood, and flowers, but his exalted vision of life and love is served well by his linguistic agility. Yet there are still those who question the ideas in his poetry, or seeming lack of them. Perhaps the most famous example of a poet understanding the fundamentals of his art is Rimbaud’s Vowels where he allocates each vowel a color and a metaphor that describes its effect: black A, white E, red I, green U, blue O.
These techniques, at the core are as formal as any used in programming and rely on a similar knowledge or intuitive understanding of the tools of one’s art or craft. Poetry relies equally on the shape, texture, rhythm, and smell of words and on formal meaning. The craft of poetry, as the craft of programming, depends on a rigorous understanding of the uses and abuses of language and syntax. Although the programmer doesn’t profess to higher emotions, his foundation, as of the poet’s, is precision and elegance. One thing that good programmers share with professional writers, artists, and musicians is this obsessive attention to the detailed cause and effect of what they do.
Music is mathematics. Music was once taught as science alongside arithmetic, geometry and astronomy. Music, it was known, had much to teach about the study of harmonics and harmonic principles, as well as the study of the motion of the planets and stars, or the “music of the spheres”. In 1746 William Tans’ur defined a ‘Master of Musick” in A New Musical Grammar as someone who „must not only be a grammarian, but also a Master of Letters and Languages, in order to unfold what is locked up in the Closets of the Learned – He must be an Arithmetitian and able to explain Numbers, and even the Misteries of Algebra; and also a Geometrician, to evince a great variety, the Original of Intervals, Consonant and Dissonant…”
Music is imbued with mathematics; music and the science of numbers are related and there is no doubt about it. In fact, many avant-garde and classical composers have proved that it is possible to compose aurally satisfying music on purely mathematical principles and that all music can be broken down into harmonic structures that contain an inherent numerical consistency.
The affirmation that poetry and code have a relationship beyond the mutual reliance on language and syntax raises controversies simply because many programmers think they know what poetry is and know that they don’t like it. At the same time, many poets or poetry lovers don’t understand the art of programming and have no interest in knowing about it. But in a world where the intersection of technology and arts is closer than ever before, these tribal divisions have no excuse. We thrive on media, multimedia, music, TV, video, and yet pretend that we don’t.
Understanding that programming is a form of art broadens the perspective on finding solutions that are adaptable to changing realities, new hardware, and other less predictable aftereffects. Viewing programming as solely functional limits the perspective to a short term view and the code doesn’t live beyond its immediate purpose. It’s quite frightening to look at a future populated with machines without vision for art and culture, it’s also dull.
In the end, all computer technology is built on a sequence of On and Off switches, indifferent of the assertion that good code is poetry. What the programmer has to do is to build them in the correct order. Only in the most remarkable circumstances are computer programs the work of geniuses. But the programmer who is an artist has the ability to build the commands of the chosen language into elegant structures, to create a program that is a small work of art, the best expression of the best solution. Perhaps this is why, in the right environment, programming computer code is a creative and satisfying task, perhaps this is why so many programmers contribute freely with their time and code to GNU/Linux and other free software projects.