As an industry, I’d say we’re all pretty clued up on how to be a better programmer:
- Write code and write some more code
- Read lots of code
- Write your implementation, then rewrite it, then rewrite it again
- Use meaningful names/structures
- Refactor, refactor, refactor
- Test, test, test
You get the idea.
In the majority of the Top 10 tips scattered around the internet for steps on how to be a better programmer, they lack what I consider the fundamentals. Now, these fundamentals don’t just improve your programming ability they improve your health, wellbeing and just generally make you a better human.
1- Get your 8 hours!
We’ve all seen the crazy routines of some top dog CEOs where they go to bed at midnight, wake up at 3am and read 2 books by 5am, these are absolute bullshit. And if you think can get by just fine with 5-6 hours sleep then you are wrong, In Why We Sleep by Matthew Walker (which you should read, bloody brilliant book) experiments shown that getting just 6 hours of sleep just one night can decrease cognitive performance by 20%.
And this fact, which I think is particularly worrying for us programmers:
subjects who got six hours of sleep a night for two weeks straight functioned as poorly as those who were forced to stay awake for two days straight.
I’ll be honest, the above fact scared the living shit out of me. Whilst I was at University I would frequently get by on very little sleep. I supplemented my fatigue with a tonne of energy drinks and coffee, why sleep, when I could be studying? Only now do I realise how naive I was.
The best thing I ever did in terms of ensuring I was getting enough sleep was purchasing a smartwatch. I used to do the classic counting how many hours sleep I’ll get if I go to bed now:
it’s 11pm and I need to be up at 5am, that’s 6 hours sleep.
In reality, it’s probably about 4 hours max. A smartwatch is really good at telling you how long you were sleeping and how long you were awake in the night, I quite often have sleeps where I’m awake for over an hour in the night. allocatedSleepTime !== sleepTime
2- Step away from the computer
Ever been stuck on a bug for a long period of time, scratching your head, questioning life, and then the moment you leave the room as you’ve had enough or it’s hometime the solution suddenly comes to you in a stroke of subconscious genius? You’re not alone, some of the greatest discoveries have been found when people weren’t actively looking for them:
- Newton discovered gravity under the comfort of his apple tree
- Archimedes was having a bath when he came to understand that the volume of water displaced must be equal to the volume of the part of his body submerged.
- James Wright in 1943 combined silicone oil and boric acid to find a cheap alternative to rubber for tank treads, he ended up creating Silly Putty.🤣 Okay, this one doesn’t quite work, but you get the idea.
It’s good to take a step away, occupy your mind with something else and go back to the problem with a fresh pair of eyes!
3- Get moving
Programming can be bloody stressful, you can spend all week working on a problem that you’ve estimated to be a one-line fix. You can have managers getting at you for taking too long to implement a feature or for introducing new bugs to the system. You might have 10x engineers in the office making you look bad, etc, etc.
Us programmers can be sat in our chairs for over 12 hours. Humans haven’t gone through six million years of evolution for us to be hunched over our computers all day. There’s plenty of scary articles explaining why sitting is bad for us.
One very effective way to combat stress is to exercise. Whether it be going to the gym, going for a run, going on a bike ride, a walk or playing a sport. Whatever it means to get your body moving do it!
Everyone knows the benefits of exercise but not everybody does it. Set yourself a goal, go X times per week, run X amount of miles.
I tend to go to the gym on workdays on my lunch break (Gym is next door to office), and go running every now and then, recently with the goal of running 20 miles a week (I’m pretty good at not doing the 20 miles🤣).
Running to me is like an active meditation, just getting outside with no route, no goal and getting lost is one of my favourite things to do. Humans were born to run (Another brilliant book).
4- Drink, drink drink. (Water that is)
We love our coffee, our energy drinks, our mountain dew but most of us just don’t drink enough water. Being hydrated is so important for cognitive performance, overall brain function, energy levels, weightloss the list goes on and on.
It is recommended that you drink 2 liters of water a day (Half a gallon). I like to fill my liter bottle up in the morning and I know I have to finish it by midday and fill it up again and finish it by the time I leave work, most of the time filling it up a 3rd time to go to the gym at lunch.
Being a programmer requires long sessions of intense concentration and yes, you can fuel this concentration by using caffeine, but it doesn’t last for very long at all. Keeping your brain hydrated gives you a more sustainable focus than the 30-minute kick you get from downing a coffee.
So to become a better programmer, you better be necking some water.
Our brains are going 100mph, continuously, like an endless washing machine of emotion, even more so for us programmers as 80% of our job is thinking; trying to create an elegant solution for a complex problem. Sometimes it is good to take a cognitive step away from it all. Meditation can reduce stress, reduce anxiety, improve attention span and even alter the structure of the brain; increasing the size of the hippocampus which is the part of the brain that controls memory (particularly long term) and regulates emotion.
This is one I’m not particularly good at but am in the process of learning. I often struggle to get to sleep as my brain is essentially overclocked, thinking of potential features I could add to my app, stuff I can write in my blog or ideas that’ll make me a millionaire.
MY BRAIN JUST DOESN’T STOP.
10 minutes of meditation though, and I’m out like a light.
I use headspace which is an app that has a tonne of features to help you meditate. I particularly like the guided meditation as I often get lost in my thoughts and its good to have the gentle reminder every now and then to come back to the breath, plus I just love Andy Puddicombe’s voice.
Taking time to do nothing is an investment we can all make, just 10 minutes a day. “Most people spend more time on their hair than they do on their mind” – Andy Puddicome.
And that’s about it! I’d love to hear your thoughts and potentially ideas that I’ve missed for becoming a better programmer without touching your keyboard.