Exploring Creative Code: Week One
My goal as a programmer is to write beautiful code.
Throughout time, human beings have always expressed themselves through art.
Art has evolved over time, as have the tools that artists use. Creative people are always expressing themselves with ever-changing methods and techniques, with new forms of art usually being derived from new sets of tools. Primitive forms of painting made way for more advanced forms, which in turn made way for film and countless other modes of artistic expression.
I’m by no means an expert on creativity or the artistic process, though much of my work has taken an artistic flair. For example, I’ve worked as both a freelance journalist and video editor, and it’s clear to me that I’ve always been attracted to the ways I could marry my creative interests with my professional life. Fortunately, code has allowed me to continue doing that.
One of the first things that attracted me to computer programming is that writing code gives the designer an open world to create anything they want. Anything that a programmer can think up can travel from their brain to their fingers to their IDE and on through the electronic guts of the machine until you see the words “Hello World” appear before you, as though by magic. It’s an exhilarating feeling, one that every coder knows intimately.
As with anything, though, good code is hard to write, blending elements of art and science in complex ways. Talented programmers aim to write beautiful code (often referred to as elegant code), which can be appreciated by those in the know for its simplicity, readability, and efficacy. While precise definitions of elegant code are hard to come by, programmers often point to this phrase from the author of The Little Prince, Antoine de Saint-Exupéry:
“Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.”
Or, as MIT Professor (and pioneer of using code as a creative medium) John Maeda puts it, take your code and “Reduce, thoughtfully.” Take the two code snippets below. While both pieces of code do the same thing, the snippet on the right is shorter and simpler, introducing fewer possibilities for error overall.
Although producing elegant code provides countless opportunities for software engineers to express their creativity, there is a growing movement of programmers that want to use code to explicitly create artistic artifacts, especially using frameworks and languages like Processing.
Readers of this blog will know that I’ve written about Processing and the creative coding community before, but at a high level, Processing is a language that facilitates creative expression through the medium of code. Aiming to educate design-minded people on how to apply their creativity to computer as well as teaching programmers about design-oriented principles, Processing’s sketches represent a new artistic mode.
While still in its infancy (Processing itself was borne out of an MIT project that began in 2001), the creative coding community is quickly growing in size and influence.
Of all the people working in the creative coding space today, by far my favorite Golan Levin. A professor at Carnegie Mellon University, Levin been thinking for decades about how code can be used for art.
Levin’s work sits at the intersection of humans and computers, contemplating the ways people interact with computers and how we might do so in the future. Levin’s artistic output is also self-reflective in nature, aiming not only to create artistic artifacts through code but also to examine the artistic process using computers. As computers are increasingly used as tools for creativity, artists and thinkers like Levin are able to “get under the hood” of the creative process and examine it from a new perspective.
If you’re curious for more details on Levin’s past artistic projects, I’d encourage you to follow his work here.
I was so inspired by Levin’s work and his thoughts on the creative process that I knew I had to learn more. Luckily, earlier this year I was able to buy his book. Co-written with Australian artist Tega Brain, Code as Creative Medium (CaCM) is a collection of coding prompts and assignments about writing creative code.
CaCM itself is dense, containing details on the history of creative code as well as extensive interviews with current educators in the creative code space. These interviews are wide-ranging, and they flesh out the community’s hopes for what this form of artistic expression will ultimately lead to.
While these elements are interesting, perhaps my favorite feature of CaCM is the series of exercises and prompts to challenge and encourage the reader to ply their own creativity to the coding process. With these exercises — which include creating a face, representing time in a unique way, or designing a game that simulates whack-a-mole , among others— readers are invited into the creative coding space themselves, lending an opportunity to think critically about and contribute to this growing field.
Over the next several weeks, I will be working through the exercises in CaCM and blogging about it here. I’ll be working primarily in p5.js, a JavaScript library designed to make creative coding accessible to everyone. Similar to Processing, p5 uses the concept of a sketch as a way to frame code. Whereas traditional software engineering stresses a “measure twice, cut once” approach to writing code, users of Processing and p5 approach code like sketching, where keeping the end result of a project open-ended allows the designer to explore new possibilities.
As an example, a simple sketch in p5.js might look something like this:
But as with any creative outlet, the possibilities are endless, and p5.js programs can get incredibly complicated.
While I have no illusions about becoming the Picasso of creative code, through this project I hope to accomplish a number of things. First and foremost, I want to improve my skills as a software engineer. By working through CaCM’s assignments, I hope to challenge my coding abilities in an unconventional way. Using this kind of lateral thinking to boost my problem solving skills will ultimately aid me in thinking of creative solutions for professional, production code.
Secondly, I love making things, and want to be able to use my love of code to scratch that itch. As any software developer knows, it’s exhilarating to take your ideas and turn them into a computer program, and creative code offers a new avenue for that feeling. While all computer programming provides an outlet for creativity, my hope is that creative code generally and CaCM specifically lends a new vantage point to explore my creative expression with code. Check back here and on my Github page to see my progress week to week, and thanks for reading.