Treating Code as an Essay

This was a chapter from the book Beautiful Code. I am doing some random sampling of various chapters. Some notes from this chapter on Treating Code As An Essay by Yukihiro Matsumoto, designer of Ruby programming language.

These are quotes from the chapter. I formatted them a bit.

Lightweight Languages are not lightweight in the sense of ease of implementation, but they are called lightweight because of their intention to lighten the workload of the programmer.

Brevity is one element that helps make code beautiful. As Paul Graham says, “Succinctness is power.” In the vocabulary of programming, brevity is a virtue.

Brevity can also mean the elimination of redundancy. Redundancy is defined as the duplication of information.

In order to eliminate redundancy, we follow the DRY principle: Don’t Repeat Yourself. The concept of DRY is the antithesis of copy-and-paste coding.

Simplicity is the next element of beautiful code. We often feel beauty in simple code.

When simpler tools are used to solve a complex problem, complexity is merely shifted to the programmer.

Balance is the final element of beautiful code. So far I have talked about brevity, conservatism, simplicity, and flexibility. No element by itself will ensure a beautiful program.

This chapter is a great read, as are many others I am sampling right now.

Update: 14th Apr 08

Just found that there is a 3-part series of videos. Here is part-1.

One of the highlights at the recent SD West 2008 conference was the panel discussion on “Beautiful Code” that I had the honor of moderating.

Based on the book of the same name, the Beautiful Code the panel was made up of six of the 33 contributors to the book — Michael Feathers, Jim Kent, Christopher Seiwald, Elliotte Harold, Ron Mak, and Alberto Savoia. As I previously said, my job was to make sure the panel had plenty of bottled water.

To give you a flavor of the panel discussion, here’s a video excerpt of the event. We’ll have more clips in the near future.

3 thoughts on “Treating Code as an Essay

Comments are closed.