How To Hack Your Habits For Learning To Code

When I first started learning to code, I found that I really lacked patience. In today’s world of instant gratification (thanks Google and Apple!), knowing that you cannot instantly become a good programmer is a deal breaker for many people (whether they know it or not).

When I first encountered bugs in my programs, I immediately panicked and quit for a few hours or even days if I couldn’t solve it in a few minutes. So, to really learn to program, I had to step back and re-program myself to live in a world of patience and long-term goals…


Just to clarify, I believe it’s important to have long-term goals not just for programming, but for your health as well. Our body and mind are one, so if you’re impulsive with your body, you will be impulsive with your mind. We are at our best when our body and mind work together.

So here are a few ways I hacked my habits so I could have more patience, which has come into handy a lot more than I first realized as I keep learning to program:

10 Minutes Of Meditation

I cannot recommend meditation enough. Just 10 minutes before bed every day will make a HUGE difference in how you think. I use the Headspace app  to walk me through the meditation right before going to sleep.

One thing that meditation helped me realize is that programming is more of a 10 year goal (at least!), so today is only one day out of 10 years. It’s ok to take your learning slow. Just learn a little every day, and it will compound before you know it!

Blocking Social Media

When I got stuck on a bug, I used to immediately go to Facebook or Twitter or Hacker News or Gmail to “take a break”. I ended up spending way more time on these sites than learning, so I knew I had to do something about it. Googling around, I found the Self Control App, and it made a HUGE difference.

Instead of jumping away from the problem, I was now forced to lean into it. My bugs got solved a lot quicker and I ended up learning much faster than I thought I could. Now, I just do my social media stuff in the morning, and thanks to Buffer, I can schedule my Social Media interaction throughout the day.

The Eating Healthy Trick

Eating healthy boils down to not having unhealthy food around. If I have a cookie around, I know I will not have enough self control to NOT eat it. So I only keep healthy fruit and vegetables nearby, so whenever I’m hungry, that is the only option for food.

I also try avoiding going out to restaurants a lot, since the food there seems to be unhealthy, and I make sure I eat before attending events that serve unhealthy food (if I’m not hungry, I can avoid a slice of pizza much easier). Eating healthy helps me keep a much clearer mind, so I can get the most out of it!

Exercise As A Habit

Programming requires a lot of sitting in a chair in one position, so I highly recommend getting at least a little bit of exercise every day. Just like with programming, I see exercise as a more long-term goal, so I only do as much as I can every day. It is better to be persistent with exercise every day rather than pushing yourself to the limit once a week or less. Building the habit of exercising is more important than the exercise itself.

I prefer to exercise at night, mostly because my mind is pretty fried by the end of the day, so staring at a computer screen some more doesn’t do me much good anyway.

The Sleep Revelations

While the Hacker culture supports staying up all night to keep hacking, I personally think it is counter-productive to do that. Getting 8 hours of sleep has accelerated my problem solving skills by hours as I’ve been learning to code. A bug that took me 2 hours to try to figure out the night before (and which I couldn’t figure out on my tired brain), takes me a minute to fix as soon as I wake up.

While you sleep, your brain does the work of thinking through these problems and connecting the dots that you couldn’t connect the night before. I love waking up and knowing the answer. It’s much more pleasant that staying up all night instead just to come to the same answer.

That is the reason I don’t attend all-night hackathons. While it’s cool to build something in a weekend without getting much sleep, it messes up your sleep schedule for the entire week (it take the whole week to make up for the sleep lost in a day!), which, to me, is just not worth it.

The Hard Way

As you can probably see, all these things are really HARD to do, especially with the constant temptations and peer pressure that our environment provides us. Well, if it was easy, everyone would do it.

To change your life, you have to choose the HARD WAY.

Enjoy the article? Join over 20,000+ Swift developers and enthusiasts who get my weekly updates.