Elegance -- that one mystical property that all geeks hold dear to their hearts. Whether we are programmers, computer scientists, mathematicians, or physicists, we all value elegance. In fact, it can be said that it is this appreciation that separates the true geeks from the interested by stander or tradesman. It goes beyond a simple curiosity to a true appreciation for an innate beauty that the outsider cannot understand.

Fine, that is all nice and good, but what is elegance? I mean really. We can look at things (programs, theories, solutions, etc.) and say whether they are or are not elegant, but what is the litmus test? The first one to chime in that it is entirely subjective gets whacked on the head with the planet Neptune. Elegance is not in the eye of the beholder. Elegance is the ability to boil the entire solution down to one unifying idea that holds throughout the whole. By extension this means that the fewer special cases are involved, the better. The perfectly elegant solution wouldn't even have to handle special cases--they would all be taken into account automatically. Of course, we seldom get that far, but that is the goal. Yet one last way of stating it is, the closer you've come to completely satisfying Occam's Razor, the more elegant your solution is. Don't believe me? Let's take some examples.

Particle physics is about as inelegant a solution as one could ask for. Sure, it works (in fact, it was the best experimental track record in modern science), but physicists are increasingly dissatisfied with it because it is inelegant. Let's take a closer look.

Calculus. Now Calculus IS elegant. No whining stories about how hard it was to learn or whatnot, it IS elegant. The finest example of just how elegant it was, for me personally, was in Physics II during my last undergrad semester, when we started doing Gaussian surfaces. The professor showed us two ways to handle the problem, with a convoluted algebraic formula that we could memorize, or a couple of integral equations that we could memorize and use to derive the equation needed for the problem at hand. The second method won hands down. What about what I said earlier? Can Calculus be boiled down to one essential idea? Yes, it can. It is the idea behind the limit and, consequently, behind the derivative and integral as well: it is the idea of breaking some potentially horrifically complex surface/line/whatever down into infinitesimally small pieces which are relatively easy to compute, and summing them up to get an estimation for the answer. In theory, if we could sum a truly infinite number of these little deltas, we would get the One True Solution. In practice, the error is so small we take the answer to be correct.

So why is it important? Is it a mere aesthetic pleasure? No, I would argue not. I would argue that it because elegance is tied to simplicity, that elegant code is better, more maintainable code. Notice here that there is a big difference between "clever" code and "elegant" code. Most clever code is not in the least bit elegant. Very often, "clever" code relies on a non-obvious complex property of the system to make itself work, thereby making it harder to understand what it is doing, how, and why.