---
title: "The First Virtue of a Programmer"
canonical: "/2017/05/24/the-garfield-spirit-of-programming/"
date: "2017-05-24"
author: "Alok Singh"
tags: []
---


This Garfield strip has a lesson in it.

![The soul of a
programmer.](/assets/garfield_lazy.gif)

You need a certain amount of laziness to build cool tools. Patience is
usually a virtue, but sometimes it causes you to tolerate typing in the
same thing over and over.

[Larry Wall](http://wiki.c2.com/?LazinessImpatienceHubris) appears to
agree with me. Well, he said it first, so really *I* agree with *him*.
But it's my blog, not Larry's.

> ## 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. Also hence, this book. See also impatience and hubris.

I know a guy who types `git commit -m` every time, and uses *escaped
newlines* to type a commit message, rather than use Vim for it because
he doesn't want to learn Vim. He's also unwilling to take the 5 minutes
to figure out how to set his `$EDITOR` environment variable to Sublime
Text, so that he can just open it in there.

This makes him averse to typing detailed commit messages. My condolences
to his teammates.

He never uses Makefiles. Instead, he types out every single filename if
there are less than 20. Any more, and he uses this command that he
looked up:

``` {.bash}
for i in `find . -name '*.c'`; do cc $i -o $i.out; done
```

This is a bad idea since it involves re-compiling every file in that
directory, and doesn't recurse into nested directories.

A lazier person would create a Makefile.

He also spends several minutes a day formatting his code nicely. I'm all
for nice looking code. But I'm lazy. So I took an hour to find
auto-formatters for every filetype I normally use, and an editor
extension that auto-formats on save.

So I now write sloppily formatted code that looks even better than his,
because man can't beat machine in this.

The takeaway, which Larry was kind enough to say lucidly 26 years before
me, is that you should spend a little energy now to save a lot of pain
later. If nothing else, it's less boring to solve your problems in a
novel way.
