Tuesday, May 19, 2015

Code, Creativity, and Beauty

Earlier today I was teaching a class on scrum and XP practices.  During the course of a conversation on Test-Driven Development I made a statement to the effect of “I want to let my tests drive out my design, and not the other way around”.  One of the individuals in the class protested against this. Not against TDD mind you, but against the idea of simply following the narrow path and narrow design that the test was going to cause.  His position was that this method pays no heed to the “creative nature” of software development.  There was further conversation regarding the nature and implementation of TDD that isn’t pertinent here, but his statement stuck with me.

Is there an inherent creativity to software development?

This thought stayed with me for the rest of the day, and as I was washing the dishes just minutes ago I had a sudden dialog in my head on the subject.  You might say (ironically) that my muse visited me, and I was inspired to do something creative.  I rushed to finish the dishes and feverishly started writing out these thoughts before I lost them.

In my daily practice I do not typically stop to consider if, while test-driving a feature, what I’m doing is creative in nature.  I’m building useful things.  These things are going to be employed by someone for a purpose.  Their nature is that of tools, albeit sophisticated tools which are capable of great feats. I know what the thing should do, and I’m writing test code in a way to force the behavior of the code.  Is that creative?  Obviously the simple act of putting syntax to electrons is creative in the sense that you literally just created form and structure where none were before, just as putting these words together for you to read is a creative act.  The question I’m asking is whether there is anything inherently creative (aside from the act itself) in writing code beyond fulfilling a purpose?

Another thought: Can code be considered “beautiful”?

The individual in question also made a comparison of code to music score which I honestly can’t remember now.  I wish I could, but again, this got me thinking.  From my point of view, music and code come from two very different worlds.  Music is creative and beautiful and simply is.  It has not been written to serve a purpose beyond mere entertainment, while software development in general and code in particular was very specifically created to be utilitarian.

There is certainly code which is written purely to be creative and beautiful.  One need search no further than Perl Poetry for examples.  However, ask the average developer if the code that they are working on is beautiful and see how they respond.  They may surprise me, but I think my chances are more than just good that they would describe what they were doing as creating tools to serve a purpose, and beauty and creativity be damned.

Having said this I certainly don’t believe that the act of creating something is in any way at odds with imbuing it utility and purpose.  As a software developer I’ve seen (and endeavored to create, successfully or not) code which is elegant in its simplicity and utilitarian in its application.

Supposing code can be beautiful, how it its beauty derived?  Is is beautiful because it serves a purpose?  Or can it be beautiful simply in its own right?  Can a shovel be called beautiful?  After all, code and shovels are tools which both serve a purpose, though the shovel is infinitely more simple (elegant?).  There is the old saying that beauty is in the eye of the beholder, and that may be so.  If it is, then all code, regardless of its function (or non-functioning nature as the case may be!), could potentially be called beautiful.  This is a concept that is beyond my normal thought processes.  If a thing created for a purpose fails in its purpose can it still be considered beautiful?  If I can’t use the shovel to move material from one location to another can it, as a tool, still be considered beautiful?

To use a metaphor which is probably more familiar to most software developers, can a brick in a cathedral be considered to be beautiful?  Yes, the brick might be used to build a cathedral, and I believe it is a safe thing to say that most people consider cathedrals to be quite beautiful, but is the brick itself beautiful? To take the metaphor further people often point to cathedrals in awe, stating how incredibly beautiful and inspiring they are.  They point to elegant arches, flying buttresses, and columns, and remark at the feelings they invoke in the onlooker.  In deed, part of the purpose (see what I did there?) of cathedrals is to cause a sense of awe and grandeur in worshippers.  The church and its architects, purposely designed it that way.  They also, by the way, designed the arches, flying buttresses, and columns for specific purposes as well.  All of them in their own way support the system of the cathedral, that is they keep the building from collapsing in on itself.  Can they be considered beautiful?  Certainly, as history and wide opinion shows us. However, at the same time they are far more *useful* in purpose than many people realize.  Were they created to be intentionally beautiful while at the same time serving important purposes, or were they simply created to fulfill a purpose?

As software developers is the act of writing software inherently creative, and is the code inherently beautiful, or is it simply the act of building a tool for a utilitarian purpose?

1 comment: