The Most Elegant Code

After years of debate about what makes readable code, its becoming clear to most developers that most of the time, the best code is also the shortest code.  I’m not saying you should pretend it’s fortran and use variables like “i”, “k”, etc.  Likewise, I’m definitely not arguing that you should strip comments!  But, for any logical statement, if it can be reduced, it can be made better.

When you are trying to write something that has few loopholes or bugs, writing it more succinctly is often the way to do it.  Further, by writing in the shortest form, code becomes similar, even if it didn’t come from the same author.  Verbose code, on the other hand, has more opportunities for mistakes and more opportunities for logic flow that doesn’t do what you think it does.

Now that I’ve deceived you into thinking this is a post about software, I’ll tell you what it’s really about:  lawyers.  Software developers have only really existed for 30-40 years.  Yet, in those few years, we’ve managed to figure this out – fewer lines of text is simpler.  Lawyers, on the other hand, have existed for thousands of years and still haven’t figured out that the simplest, most truthful, and least buggy way to describe something is with fewer words.  Perhaps lawyers seek not the truth.

Leave a Reply

Your email address will not be published. Required fields are marked *