How to write code like Ernest Hemingway

This is interesting to me. Hope to you too! Happy new year to all! Best Christine

By The Manila TimesDecember 29, 2019

Books of Ernest Hemingway are a matter of taste. Some love them, others not so much. But despite that, there’s a lot you could learn from Ernest Hemingway. In this article, there are tips from the writer that could help to improve your writing as well, even if your writing is code.

Study the greats

Before even starting programming, you should be curious about others who have already written some great code. Hemingway said: “[A writer] should have read everything so that he knows what he has to beat.” It doesn’t have to be all about competition. It’s more about the inspiration you could get from different approaches to writing code.

To study great examples of code, you don’t need to go under the hood of various projects.

Many books analyze the best examples and tell stories about how people came up with them. Arnas Stuopelis, chairman of the Board of web hosting provider Hostinger, said: “One of the Hostinger values is learn and be curious. We have a bookshelf in the middle of our office and suggest people ordering any book they want. It doesn’t always have to be work-related. But if it motivates a person, it’s a valuable investment.”

Block out negative thoughts

Randall Degges has a blog, “Random Thoughts of a Happy Programmer.“ In it, he writes:

“If you’re a programmer and stay up-to-date with community happenings via Hacker News, you’ll almost certainly notice a trend: there are lots of popular articles focusing on the negatives (mean rants, public shaming, outrage about various issues, etc.).” All those little details lead to feeling blue.

It could be intimidating to work on a project when you are in a negative state of mind.

Then remember Hemingway. He said: “Once you are into the novel, it is as cowardly to worry about whether you could go on to 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… As soon as you start to think about it stop it. Think about something else.” Questioning your abilities won’t do any good. Be easy on yourself, remain consistent, and continue what you started.

Be brief

Hemingway didn’t respect writers who, as he put it, “never learned how to say no to a typewriter.” But the same goes for a keyboard. When you could write part of the code more shortly, do that. There are no advantages to having more lines. It’s the opposite — the more lines you have, the bigger the chance to make a mistake in one of them. So remember to be brief.

Practice empathy

Hemingway advises: ”As a writer, you should not judge. You should understand… Listen now. When people talk, listen completely. Don’t be thinking what you’re going to say. Most people never listen.” As for developers, it’s quite stereotypical to see them as someone who is only logical and numbers-based.

But the truth is that the developer has to be empathetic first. Kent Beck, the American software engineer and the creator of extreme programming, said: “The craft of programming begins with empathy, not formatting or languages or tools or algorithms or data structures.” When writing code, remember that you do it for people. Keep them and their needs in mind without judging.

Always stop when you’re going good

This one is probably the most known Hemingway’s tip: “The best way is always to stop when you are going good and when you know what would happen next. If you do that every day when you are writing a novel, you would never be stuck.” But it works not only with novels. BBC summarizes it this way: “not finishing a task could be beneficial.”

BBC quotes Manalo, who researched this topic: “We need to have belief in ourselves — some kind of expectation that we could do something. And when we’re closer to finishing something that we had previously failed to achieve, then that optimism increases.” When you stop working at a peak, you would feel more comfortable to get back to work the other day.

Never think about the story

It isn’t easy to not think about work when you are not working. But it’s crucial. Hemingway wasn’t any different. So, he had to create a distraction for himself: “It was necessary to read in order not to think or worry about your work until you could do it again.”

As for developers, Joe Petrakovich suggests a more suitable way to disconnect from work.

He calls it Personal Standup. He creates a markdown file and writes his tasks for ## TODAY. Joe suggests: “As you work, be sure to mark items as DONE. Don’t delete them though. They stay as visual aids, so we know what we’ve accomplished.” If he hasn’t done the task by the evening, he moves it to ## TOMORROW, so ## TODAY would be all done. The list of done tasks makes it easier to wrap up the day and don’t bring work home.


As a writer, Hemingway used to be at the typewriter for extended periods of time. So, he said: “It was necessary to get exercise, to be tired in the body, and it was very good to make love with whom you loved. That was better than anything.” There is a good chance that you, like Hemingway, spend quite a lot of time sitting, but this time, in front of your keyboard.

Sitting for long periods of time has a significant effect on posture. A person starts to extend a neck, brings face closer to the keyboard. Then hunches shoulders forward and slumps in the chair. Simple Programmer warns: “When we sit down, certain parts of our bodies shut down. Our muscular and cellular systems were put to sleep, causing our chances of things like diabetes to increase.“ Regular exercise could help to avoid all of that and more.

As a programmer, you could seek inspiration from various places and people. Ernest Hemingway sat in front of his typewriter. But his tips are usable even for those in front of the keyboards.

To get even better at programming, you should learn from the best and study their work. Believe in your capability and ignore negative thoughts. When writing code, be brief and learn how to say no to the keyboard. Be empathetic and try to understand the people who would use your work.

When working, try to stop at the time you feel the best. This way, it would be easier to get back to work the next day. But once you are done with this day, do your best to rest without thinking about what’s left to do. And one way that could help to do that is exercise, which is beneficial for you on many levels.

Ram Kezel

Leave a Reply

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

Social Media Auto Publish Powered By :