Categories
Blogging Ideas Software Development

Beautiful code

A friend (who is not a developer) read Deep Work and asked me my opinion about the following quote:

Beautiful code is short and concise, so if you were to give that code to another programmer they would say, “oh, that’s well written code.” It’s much like as if you were writing a poem.

Cal Newport, Deep Work

Here are my thoughts.

The first thing that came to my mind was something I had recently highlighted in Refactoring, 2nd edition:

Brevity is the soul of wit, but clarity is the soul of evolvable software.

Martin Fowler, Refactoring: Improving the Design of Existing Code – 2nd Edition

The beauty I perceive on short and concise code is that it usually makes things easier to understand. Brevity is good for efficient communication. Be brief, but never at the expense of clarity.

Any developer might think of coding as communicating (in a programming language) with a compiler or interpreter, but I’ll quote Martin Fowler again, “a compiler doesn’t care whether the code is ugly or clean”.

However, unless we are talking about a toy project or disposable prototype, when coding a developer is expressing what the program should do to his (or her) future self or another fellow developer who will be working on that piece of code. Shortcuts taken for the sake of keeping it short without considering clarity may obfuscate the code.

I have mixed feelings about that poem analogy. Asking the question of what is good poetry and what is not? will send us down the rabbit hole. We first need to agree on that to say if a poem must be short and concise and y’all aren’t ready for THAT conversation [insert meme here]. Actually, I’m not ready.

My humble opinion is that as developers we should pursue clarity, first. However, don’t get me wrong conciseness and clarity are not opposed, they can go hand by hand, but clarity is the source of beauty.

Leave a Reply

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