Learning to do something new is hard.

Whether it's a physical feat like reaching a new best lift or a mental challenge like learning a new language – both entail months of work, multiple setbacks, and hundreds of hours of time put in. And then you still might just be at an intermediate level.

Spending hours failing over and over again, before finally being able to do it effortlessly, is the route ahead for any beginner.

But being bad at something isn't fun.

It's hard to continue doing something you're struggling to do.

It's hard to keep coding regularly when you feel like you're making no progress with your buggy code and worse yet, aren't sure how to improve your situation.

The only way to get better is to...keep getting stuck and just persevering? That doesn't sounds very encouraging.

But that is exactly what is necessary for you to become great.

I think learning to code is especially hard, as it is so different from most other activities, and sometimes it's hard to see which of your other skills might be transferrable to programming.

But because coding is challenging to do and can be so frustrating is exactly why you should do it.

Why it's good to do hard things

Strangely, life gets harder when you try to make it easy. Exercising might be hard, but never moving makes life harder. Uncomfortable conversations are hard, but avoiding every conflict is harder. Mastering your craft is hard, but having no skills is harder. Easy has a cost.  – James Clear

I have found that the biggest leaps in my character, technical skills, and personal development normally come from something difficult I have to face.

There's this false idea amongst new developers that generally experienced developers know exactly what to do, and just "do it".

I haven't found that to be the case at all.

I have been coding for 4 years and recently wanted to create an automated job that would run a Node script monthly. Then at the end of the Node script running, it would commit the file with all results to a repository on GitHub.

I got it all wired up pretty quick, but couldn't work out for days why this script wasn't committing anything into my repository.

I was trying to work out if the Node script wasn't running, or if it was running but wasn't committing.

I tried what felt like everything. I contacted developer friends. But they had no idea what was wrong either.

Everything worked on my machine, why was this so hard?

I finally solved it. The machine that was running my Node script was a different OS than what I was using (it used Ubuntu) and was a case-sensitive shell, whilst my shell wasn't case-sensitive.

So although it worked on my machine it "blew up" on the other machine as I had the casing of the file (that I wanted to commit with all the results in it) wrong.

Here's the commit where I fixed it.

In that moment I just wanted the bug fixed.

I was sick of not being able to properly debug the issue, as I didn't have access to the machine that was running my code. I felt like I was guessing as the feedback loop was so slow.

But now that I have experience doing this, I know how to optimally debug these types of situations again.

The only thing I'm trying to show you is that the only way to improve is to struggle and work things out. No matter how slow it feels.

In my experience, the only difference between the state I was in as a newbie coder who "didn't get it" and the state I'm currently in is that I just didn't quit.

Investing in Loss

There's an excellent way to frame "getting better means struggling, persevering and not giving up" called Investing In Loss.

If you want to get good at something, you need to spend a lot of time being bad at it. View loss as an investment, rather than something to avoid.

This concept is from the book The Art of Learning.

To master any new skill, you need to go through a prolonged period of being bad before you can be good.

Each new part of software feels like a whole new world you have no experience with: deployments, networks, coding, data-structures, documentation, the list goes on. And there are multiple times – even when you're experienced – that you'll feel like you're a beginner again.

Often times the thing holding us back is our expectations of where we should be and losing patience with the process before we have finished it.

If you're good at other things, going back to being a beginner is jarring.

But you need to focus on viewing the loss as an investment – and not giving up too soon.

Don't quit!

I have not failed 10,000 times. I have not failed once. I have succeeded in proving that those 10,000 ways will not work. When I have eliminated the ways that will not work, I will find the way that will work.Thomas Edison

There are always times to cut your losses, but if programming is something you sincerely want to improve in, either for a new career or for pleasure – don't give up.

When I first started learning JavaScript, I spent time coding in the Eclipse code editor as I thought Java was the shorthand name for JavaScript.

If you aren't aware, they're not the same, and that editor doesn't (natively) work with JavaScript!

There have been countless times when I was a newbie, where I have gone through interviews and felt like I completely failed them, only to be surprised later when I got a job offer.

Remember the reason you first started learning and just keep going. Any progress no matter how small, is valuable.

Conclusion

I remember so clearly years ago a time when I was coding on freeCodeCamp and was very disheartened about how stuck I was on a particular problem.

I read this article, and it was one of the many articles that formed my opinion on this topic, inspired me to keep going, and to write my thoughts in this article.

If you're a newbie coder, I wrote about steps I took to improve as a developer here and maintain a list of high quality coding resources here.

I tweet my articles here if you would like to read more of my writing.