Beautiful Code for Beginners

Last Wednesday, we saw a presentation on beautiful code by Marcel Molina from RubyConf ‘07. It was a very interesting talk, and I was excited to start being exposed to the world of ‘beautiful code,’ which I’ve heard a lot about. Yet as we watched it, I found myself asking what the role of ‘beautiful code’ is for beginners. Why, if at all, is it important to think about? What can we derive from it as fledgling programmers?

Molina began by looking at Greek philosophical and artistic explorations of the concept of beauty. For the Greeks, from art to religious expression, beauty was a matter of proportion. When things were beautiful, they were good and goodness was beauty in action. One can think of Greek temples as a manifestation of this relationship between religion, creative expression, and mathematical proportion.

Molina takes this idea of ratio and proportion to the world of one’s code. He discusses three objectives: proportion, integrity, and clarity. Code should not be too much of one of these three traits, but rather should balance between them. Each section should be responsible for and proportional to its role.

This raises interesting conceptual questions about code, and how it fits into a larger expressive tradition. Who is beautiful code for? The programmer? The user? Both? Is this just a mechanism to help the coder feel a more tangible connection to a larger narrative?

Furthermore, as a beginner, I asked myself what this should mean to me, if anything?

First, I think that beginners can and should be driven by the constant strive towards more integral proportion. It seems to me that Molina thinks not that we should not strive to a certain ‘golden ratio,’ but driven by the concept of ratio in general. As beginners move from single-unit to more complex code, having a sense of what the role of each part should be will create a better and more versatile product.

Second, for beginners, who have been spending most of their lives until now doing things besides coding, thinking about code in these untraditional terms of beauty and goodness can invoke references to other parts of the beginners life, and start to create pathways for leveraging how they have sought to create clarity, proportion, and integrity in those areas to their coding process. Furthermore, it can clarify alternative solutions when one is stuck thinking in a certain way about a problem.

Third, I think we’re all taking part in larger projects of structured creative expression as individuals and communities. Being able to link code to this, and this to code, should hopefully be useful on both a conceptual and functional level, helping beginners get to where they want to go in terms of a contributing and learning environment.

Comments