How To Write Code Like Ernest Hemingway Would
Ernest Hemingway's works are a matter of taste. Some of us love them, some — not so much. But despite all, there’s a lot to learn from Hemingway. Here are tips from the writer that can help to improve your writing as well, even if your writing is code.
Before you begin programming, you should be curious about other programmers who have already written some great code. Hemingway said: “[A writer] should have read everything so that he knows what he has to beat.” (Read The Pioneers of Computer Programming.)
It doesn’t have to be all about competition. It’s more about the inspiration you can 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. There are many books available that analyze the best examples and tell stories about how people came up with them.
Hemingway Says: 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 can be intimidating to work on a project when you are in a negative state of mind. Then remember the Hemingway. He said: “Once you are into the novel, it is as cowardly to worry about whether you can 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.
Hemingway Says: 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 can 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.
Hemingway Says: 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. (Read 10 Things Every Modern Web Developer Must Know.)
But the truth is that the developer has to be empathetic first. Kent Beck, the American software engineer and the creator of extreme programming, says:
When writing code, remember that you do it for people. Keep them and their needs in mind without judging.
Hemingway Says: Always Stop When You’re Going Good
This one is probably the most known Hemingway tip:
“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.” But it works not only with novels. BBC summarizes it this way:
“Not finishing a task can be beneficial.”
BBC quotes Manalo, who researched this topic: “We need to have belief in ourselves — some kind of expectation that we can 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 will feel more comfortable to get back to work the other day.
Hemingway Says: Never Think About The Story When You're Not Working
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 todo.md 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.
Hemingway Says: Exercise
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. (Read Beat Injuries With These 4 Computer Ergonomics Tips.)
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 can help to avoid all of that and more.
As a programmer, you can 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 will use your work.
When working, try to stop at the time you feel the best. This way, it will 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 can help to do that is exercise, which is beneficial for you on many levels.