Hemingway on Coding

Kindle it here: http://amzn.to/1RaZuw2

Ernest Hemingway On Writing is a book that for me sits alongside On Writing Well and Elements of Style as essential annual reading for writing good prose. The book is a collection of Hemingway quotes on the art and craft of writing, either interviews or letters from the man himself or through his lead characters, frequently also writers.

It is the book I am most likely to give you as a gift and I highly recommend it.

On a recent re-read I noticed that much of the advice is applicable to writing clean, well-crafted code. Writing a novel seems in any ways to be a similar task to finishing a big software project. From my own context as a bootstrapping solo entrepreneur, the advice really resonates. I have collected my favorites below. All quotes are excerpted from Ernest Hemingway on Writing by Larry W. Phillips, 2002 Kindle edition.

The topic of “life advice from Hemingway” will certainly raise some valid objections regarding his home life and untimely end. But the old man sure as hell knew how to write. And his personal disciplines allowed him to more or less escape the excesses and burnouts of his contemporary writers and to keep publishing better and better prose throughout his life. There are things to be learned here, if not mimicked verbatim.

The best quotes in the book are actually strictly about writing novels or other authors and are not included here, so you should still go buy it (if I haven’t already given it to you) and read it.

But let’s dive in.

Stop each day when you’re going good

Launching a big piece of software that takes weeks or months is in many ways like writing a novel. The project is so huge you can’t hold it all in your mind at once. Instead you wake up every day, try to remember where you were and try to make progress to where you’re going before you run out of steam. Rinse, repeat. The cumulative output over a series of weeks is far more important than what you can produce in any given day.

Hemingway’s advice is to always end the day when you are writing really well and you know exactly what’s going to happen next. The dopamine loop that you get when you are really coding well creates a temptation to just keep cruising. Have another coffee and code through the night until your eyes bleed. But then the next day you start out off out of ideas and out of flow and you can burn half a day unproductively trying to get back in the groove.

The best way is always to stop when you are going good and when you know what will happen next. If you do that every day when you are writing a novel you will never be stuck. That is the most valuable thing I can tell you so try to remember it.
By-Line: Ernest Hemingway, pp. 216– 217
And remember to stop while you are still going good. That keeps it moving instead of having it die whenever you go on and write yourself out. When you do that you find that the next day you are pooped and can’t go on.
By-Line: Ernest Hemingway, p. 217

When you stop, stop thinking about it

An extension of the above advice is that once you put your project down for the day, for god’s sake don’t think about it. You have to train yourself to leave it alone for the rest of the day and let your subconscious go to work. Work in the morning, stop and do whatever it takes to take your mind off the project for the rest of the day and make sure you don’t have Javascript dreams and RSpec night sweats.

It was in that room too that I learned not to think about anything that I was writing from the time I stopped writing until I started again the next day. That way my subconscious would be working on it and at the same time I would be listening to other people and noticing everything, I hoped; learning, I hoped; and I would read so that I would not think about my work and make myself impotent to do it. Going down the stairs when I had worked well, and that needed luck as well as discipline, was a wonderful feeling and I was free then to walk anywhere in Paris.
A Moveable Feast, p. 13
“Always stop while you are going good and don’t think about it or worry about it until you start to write the next day. That way your subconscious will work on it all the time. But if you think about it consciously or worry about it you will kill it and your brain will be tired before you start. Once you are into the novel it is as cowardly to worry about whether you can go on the next day as to worry about having to go into inevitable action. You have to go on. So there is no sense to worry. You have to learn that to write a novel. The hard part about a novel is to finish it.”
By-Line: Ernest Hemingway, pp. 216– 217

Recognize unproductive days

In a big software project, particularly if you’ve quit your job to start it, you always feel massively behind schedule. There is a constant temptation to spend every waking moment in front of your screen.

But hours spent coding, like hours spent writing prose, follow a power law. Some days you’re on fire and everything flows as if it was already written on the back of your skull and you’re just transcribing it. Other days you may as well be mashing at the keyboard with hooves for all the progress you’re making. The trick is to learn to recognize when you’re in a slump and to stop working. It’s not a matter of waiting for inspiration to strike, you do need to sit down to do the work on a regular schedule. But sometimes your day would be better spent recovering, recuperating, or reading something inspiring. Recognize that some days are better than others and it’s better to be prepared to really pounce when you’re feeling good than to beat yourself up about trying to crush it every day.

Am in sort of a better epoque of working now and just remembered that I always work well in the Spring.
to Arnold Gingrich, 1936 Selected Letters, p. 441

And yes, even Hemingway supports Summer Fridays.

Summer’s a discouraging time to work — You don’t feel death coming on the way it does in the fall when the boys really put pen to paper. Everybody loses all the bloom — we’re not peaches — that doesnt mean you get rotten — a gun is better worn and with bloom off — So is a saddle — People too by God. You lose everything that is fresh and everything that is easy and it always seems as though you could never write — But you have more metier and you know more and when you get flashes of the old juice you get more results with them.
to F. Scott Fitzgerald, 1929 Selected Letters, p. 306

Don’t talk about your work until it’s done

A classic trap for entrepreneurs is talking about the app your working on before it is done. Everybody is going to tell you how brave you are to have quit your job to work on this. How awesome the idea sounds and how you’re going to be the next Zuckerberg. The hits of nice brain juice you get from these discussions are so similar to your imagined version of actually launching the product that you start to lose the motivation to get to the finish line. Talking about your business before it exists is very dangerous for an entrepreneur and apparently the same honey trap is a peril for writers.

This note to Fitzgerald is perfect.

However am now going to write a swell novel — will not talk about it on acct. the greater ease of talking about it than writing it and consequent danger of doing same.
to F. Scott Fitzgerald, 1927 Selected Letters, p. 261

Not talking about it is hard. Part of the reason I think a nomadic lifestyle is a good one for an early entrepreneur building a product is that the isolation can be critical to getting shit done. I love this pre-email lifehack of telling everyone you’re staying in one hotel then moving to another.

…to write I go back to the old desolation of a hotel bed room I started to write in. Tell everybody you live in one hotel and live in another. When they locate you in the other move to the country. When they locate you in the country move somewhere else. Work everyday till your so pooped about all the exercise you can face is reading the papers. Then eat, play tennis or swim or something in a work daze just to keep your bowells moving and the next day write again.
to Thomas Shevlin, 1939 Selected Letters, p. 484

And on the danger of becoming a full-time attender of meetups and hackathons.

Writers should work alone. They should see each other only after their work is done, and not too often then. Otherwise they become like writers in New York. All angleworms in a bottle, trying to derive knowledge and nourishment from their own contact and from the bottle. Sometimes the bottle is shaped art, sometimes economics, sometimes economic-religion. But once they are in the bottle they stay there. They are lonesome outside of the bottle. They do not want to be lonesome. They are afraid to be alone in their beliefs…
Green Hills of Africa, pp. 21– 22

On boozing

Every coder has experienced at some point the magical number of beers that generates a sustained hour or so of maximal productivity, followed by a crash one beer later. Opinions on the right mix of booze and coding are myriad but I’ve found Hemingway’s regimen fantastic for long working sprints.

source: http://xkcd.com/323/

It follows:

  1. Work in the morning until early afternoon (obviously no drinking).
  2. Stop work.
  3. Get some exercise.
  4. Then drink, heavily if you like, until dinner.
  5. No drinking after dinner so you can wake up early and work again.

It feels weird to drink in the afternoon and weirder to stop at dinner, but I swear it’s a great flow for productivity and creativity.

My training was never to drink after dinner nor before I wrote nor while I was writing.
A Moveable Feast, p. 174

Why you might want to drink in the first place.

P.P.S. Don’t you drink? I notice you speak slightingly of the bottle. I have drunk since I was fifteen and few things have given me more pleasure. When you work hard all day with your head and know you must work again the next day what else can change your ideas and make them run on a different plane like whisky?
to Ivan Kashkin, 1935 Selected Letters, p. 420

… And why you might not.

I haven’t been drinking, haven’t been in a bar, haven’t been at the Dingo, Dome nor Select. Haven’t seen anybody. Not going to see anybody. Trying unusual experiment of a writer writing. That also will probably turn out to be vanity.
to F. Scott Fitzgerald, 1926 Selected Letters, p. 217

On terse, well-crafted prose

Reading a few pages out of The Old Man and the Sea is great prep for a software project. The prose is so finely crafted and minimal you can almost feel that Hemingway would have been a stellar coder.

Possibly one of my favorite lines ever written…

No matter how good a phrase or a simile he may have if he puts it in where it is not absolutely necessary and irreplaceable he is spoiling his work for egotism. Prose is architecture, not interior decoration, and the Baroque is over.
Death in the Afternoon, p. 191

On trying not to get too fancy if you want your work to last.

Try and write straight English; never using slang except in Dialogue and then only when unavoidable. Because all slang goes sour in a short time. I only use swear words, for example, that have lasted at least a thousand years for fear of getting stuff that will be simply timely and then go sour.
to Carol Hemingway, 1929 Selected Letters, p. 308

On documentation

As someone who frequently needs to Google pretty basic Ruby methods all the time, I’m not sure I can endorse this. But it’s a good quote so here you go:

Actually if a writer needs a dictionary he should not write. He should have read the dictionary at least three times from beginning to end and then have loaned it to someone who needs it. There are only certain words which are valid and similies (bring me my dictionary) are like defective ammunition (the lowest thing I can think of at this time).
to Bernard Berenson, 1953 Selected Letters, p. 809

On standing desks

No commentary necessary on this one.

Writing and travel broaden your ass if not your mind and I like to write standing up.
to Harvey Breit, 1950 Selected Letters, p. 700

The right balance of relaxation, sex and creative effort

And probably my favorite quote in the book.

Eased off on the book… in May because Dr. said I worked too hard in April, and May fine month to fish and make love to Miss Mary. I have to ease off on makeing love when writing hard as the two things are run by the same motor.
to Charles Scribner, 1948 Selected Letters, p. 636

If you liked this, I write other, typically less literary, things at tylertringas.com often from an impromptu standing desk.