Make It Look Easy

Great musicians make it look easy.

Great athletes make it look effortless.

Good code reads like well-written prose.

It’s one of the paradoxes of having a skill: the better you are at something, and the more effort you have put into getting good at it, the easier you are able to make it look. A friend of mine once commented that one of the traits that makes a good programmer is the ability to think about what several different parts of a system are doing all at the same time, but that one of the traits that makes a great programmer is the ability to minimize the need for that kind of thinking.

Thinking about what different parts of an application are doing is like being a plate spinner. Being able to keep four plates spinning in the air is an impressive feat, and a great party trick, but if each of those plates cost $1000, it’s safer to just spin one or two, to minimize your chances of losing track and letting one break. Code is the same way.

The more different things you have to be thinking about at once when writing code, the more likely it is that you will lose track of something and accidentally break your application. The best code is readable and simple; it is the code that requires you to think the least. It is the code that only requires you to spin one or two plates at a time. It is also often the code that looks easiest to write. To paraphrase another piece of wisdom from Ward Cunningham, you know you’re looking at good code when each routine you read turns out to be pretty much what you expected.

To the untrained eye, code that looks simple and obvious looks primitive and code that looks complex and unintuitive appears advanced. The reality is that complex, unintuitive code is the hallmark of the beginner programmer, and simple, obvious code is what all good programmers aspire to do well (or at least what I think we should all aspire to do well).

He had never seen a wizard work things out like this, simply by looking and touching; but Harry had long since learned that bangs and smoke were more often the marks of ineptitude than expertise. — J.K. Rowling, Harry Potter and the Half-Blood Prince

One of the ways I know I’ve really gotten something right in my code is if it looks like it was easy to write. Good, concise code is almost never easy to write, but when it looks like it was you know you’re getting somewhere.