Lessons in Laziness (or learning the less is more approach to programming)

“I choose a lazy person to do a hard job. Because a lazy person will find an easy way to do it.” – Bill Gates

Whilst laziness is ordinarily perceived to be an unfavourable quality, and not something towards which ambitious people would usually strive. However, it is perhaps better understood within the context of Larry Wall‘s “Three Great Virtues of a Programmer.”, in which laziness is joined by the equally unflattering traits of impatience and hubris”.


In the glossary of his book, Wall defines these “virtues”:

  • Laziness: The quality that makes you go to great effort to reduce overall energy expenditure. It makes you write labor-saving programs that other people will find useful, and document what you wrote so you don’t have to answer so many questions about it. Hence, the first great virtue of a programmer.
  • Impatience: The anger you feel when the computer is being lazy. This makes you write programs that don’t just react to your needs, but actually anticipate them. Or at least pretend to. Hence, the second great virtue of a programmer.
  • Hubris: Excessive pride, the sort of thing Zeus zaps you for. Also the quality that makes you write (and maintain) programs that other people won’t want to say bad things about. Hence, the third great virtue of a programmer.

In programming terms then, Bill Gates’ quote from the top of this post could be understood to mean that a task should be completed by trying to write the minimum amount of code that satisfies the requirements and passes all the tests. Indeed, this, and Wall’s subsequent definition of laziness is consistent with the Einstein Principle, which could be paraphrased as: “Do as little work as possible to get the task completed, but no less.”

Having read the details of Wall’s philosophy, it becomes apparent that laziness need not be the evil we once thought it to be. However, there remain some aspects of these “virtues” that do not sit comfortably with me. For example, laziness, even in the way that Wall defines it, could lead you to write time-saving code, but it might also prevent you from using this time to learn something new and invest in your development in the process. Impatience may well help you to write code that anticipates your needs, but if shortcuts are being made, there is always a danger. Hubris might assist you in writing better code, but it may equally prevent you from taking on the ideas of your co-workers, or at least being able to perceive things from a different perspective. I would argue that there is an inherent danger in encouraging new developers to be lazy, impatient and excessively proud.

I believe that the qualities that Wall describes can be reinterpreted in the following terms:

  • Prudence: Your resources are limited. Any steps that can be taken to maximise what limited resources you have should be taken.
  • Mindfulness: Every line of code matters. Every decision to include or not include a particular line of code is one that should be made mindful of the impact that it will have on you, those you are working with, and those who will be using your application.
  • Insight: Whilst pride should  undoubtedly be taken in your work, it is important that you can retain a degree of objectivity, that you can take on board what others have to say about your code and consider implementing a different approach if it makes sense to do so. Further, it is likely that your code will need to be accessed by others, who will need to be able to understand it in order to make necessary changes. A degree of insight and empathy for this future developer is required to ensure that your code is accessible and of a suitable quality.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s