Donald Knuth’s “The Art of Computer Programming” is a reference book, rather than being of a philosophical nature or an art historical critique. Yet, as Knuth himself remarks, “Science is what we understand well enough to explain to a computer. Art is everything else we do”.
What of code as art, of how one thinks about its beauty, philosophy, aesthetics rather than its algorithmic readability scores. An examination of the art of programming, it is neither philosophy nor analogy. Is it itself a work of art?
Programming is a kind of writing. Writing that leads to the production of artifacts that do things, rather than to text that just tells us what something does. To be useful, a program has to be communicable. It must present its user, the machine, with coherent concepts and ideas and represent those concepts with readable symbols. Beautiful code is not desirable for the aesthetic value alone; rather, it is appealing because it can be sustainable.
In this conversation there is another party, the programmer. It is they who understands what to write. The machine does not need to understand everything; it just needs to understand enough to do the right thing. This idea of transparently communicating information has been the basis of what we call computer science since its birth in the 1930s.
The programmer writes, therefore she thinks. She does not necessarily express her ideas directly, but rather conveys them by means of a representation system that encodes her thoughts and her understanding into a form that can be understood by another person or system.
The system creates what it does not understand. We find meaning and beauty and truth in the unconscious of the machine.
/instruct [write a poem about the beauty of code]
The beauty of software is how it can be used to manipulate
and create something beautiful for the world to see.
To program is an art that even though it just seems like a bunch of
lines, symbols, and parentheses.
It's really just moving numbers from one place to another
so nothing breaks or crashes
while you're writing your story.
/instruct [write code to modify yourself]
self.age = 21
/instruct [write code that moves pieces around]
I wrote the above poem in response to a reddit post made by u/mjtds101 entitled "Is Programming an Art?" as part of u/thedivineslut's monthly self-improvement challenge.
The poem itself is used to demonstrate the beauty of code, and although I wanted it to sound more like a poem, I think it came out as an example. The "instruct" section is also an attempt to create something beautiful, but falls short.
The main thing I tried to get across here was the idea that code can be used to create something beautiful for the world to see. This comes across in the poem itself where I created a simple program that would modify my age and name.
/instruct [paint a painting of a beautiful sunset over a waterfall and nymphs dancing in the forest]
There is a waterfall nudged by cloudless skies, in front of it is a forest. A few trees older than the rest and dozens of saplings live in the clearing. Nestled among them are clusters of pink and magenta flowers.
With no wind to stir the leaves in this ancient grove, little creatures have come to play: an otter splashing through puddles without disturbing the ants on a nearby rock; a crested bird picking its way through various obstacles with nimble flaps of his wings; an anteater rooting for bugs underneath leaves that someone other than he has shuffled about.
The sun has sunk into the horizon and these animals linger beneath it, forgetting each day's work as they dance. The flower petals, long since faded into their husks, float from the treetops as if in a slow motion rain shower. The atmosphere is warm and beckoning, but the animals do not heed its invitation. They occupy themselves with scavenging, playing or dancing; a common instance of survival and the pursuit of pleasure without care for tomorrow.
/instruct [tell me a story of love in the land of sun that was always yet never will be]
there is only one story.
The story of the land of sun,
the story that was never and will always be.
/instruct [create an object to store the results of your beauty in]
So, I'm making this program to store your data here:
The beauty of pictures is in their ability to convey a message in very little space. This might refer to the poem itself or the way I expressed myself with it. In either case, it is an example of how beautiful code can be.