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.

  • Thank you so much for writing this up and sharing!! As you implied, it would take time and effort to build these habits, but they seem invaluable if you want to become a healthier and more efficient student and programmer =)

  • I’m currently learning Rails development (and recently applied for Dev Bootcamp, wish me luck) and as much as I LOVE learning how to code, I sometimes have very little patience. I just want to know everything *Now*. I sometimes also have those same problems with sleep, exercise, eating, and taking “breaks” on social media sites. It’s good to see different strategies people are taking to tackle their habits when learning how to code. Thanks for this post!

    • I can totally relate 🙂 Hope you figure out the hacks that work for you!

  • SD

    All great tips, thanks.
    How did you manage “The healthy eating trick” during DevBootCamp?

    • The key to Dev Bootcamp is knowing myself and being very comfortable with how much you know and where you are in the learning process.

      I actually left Dev Bootcamp at 6pm every day and never came in on weekends, and took the break I needed to cook and get a break from being around 40 other people all day long.

      I found that people who stayed after 6pm weren’t as productive, since it was more a social scene after the official class time, so I didn’t feel like I missed out on anything, especially since I was comfortable with myself and my goals. Sure, others finished more exercises than me and much faster, but I knew I came there to fill in my gaps in knowledge, and that’s what I focused on. I knew that as long as I knew how to finish the exercise and the concepts behind it, that was the important part of me.

  • Samir Zaheer

    Nice tips ! Personally, I feel that running is the best exercise to clear your head after intensive work sessions like coding. And I absolutely agree social media is bad news for programmers

  • Stephen Conway

    Hi Natasha,

    Just a quick update; I’ve completed the Stanford CS106a lectures 1-3 and am working on the assignments. Things seem to be clearer than they were when I first tried to get through the course in 2009. I have no problem stating that the steps and resources in your book has made the learning process easier for me this time around!

    On that note, I am also having some positive results with Headspace’s “take ten” sequence mentioned in this post.

    I was going to try a one month subscription, but before I make the commitment, I was wondering if you’ve had any experience with their subscription service? If so, would you recommend it for helping improve one’s learning capacities, or any other areas of life?

    Many thanks.

    • Hi Stephen,

      Yes, I did the subscription, and it’s pretty much the same as the trial version. The only difference is that you continue on with the longer meditations every day. Try it out for a month, and if you like it and keep doing it, you can do the longer one. I really liked it!

  • Thanks for the kind words Aravinth, and Happy Learning!!!! I LOVE iPhone development, so can’t wait for you to try it out!!!

    The best way to improve your coding style is to try to program with other people who are more senior than you. Check out meetups in your area, and ask the people at those meetups to give you feedback on your code.