I’m introducing my kids to coding at the moment. I’ve just discovered Scratch and Tynker and, having fallen in love with the UI (a combination of code and coloured lego blocks), I’m encouraging them to write simple programs.

Programming is great; not just because it’s a hugely important skill in itself; but because it teaches kids some valuable lessons about life itself. Here are a few things I’ve learned:

It’s all about making mistakes.

There are few things as frustrating as coding. To get something to work right requires hours of getting stuff wrong. You can be stymied for ages over a misplaced variable name or a minus sign in the wrong place. But if you stick with it, you’ll produce something rather beautiful: something that does just what you want it to do.

That’s how it works if you want to do anything well. You have to be willing to try different things; to accept that your first drafts will be imperfect – particularly when you are trying it for the first time.There’s an awful lot of trial and error in life. Coding gives you a deep insight into this.

There is no such thing as perfection.

Programs are never finished. Even if they do their job well, there’s always something that needs improvement. Perhaps the environment changes, or you need to make it work faster. When you are responsible for a piece of code, you are often in it for the long haul.

This is true to life. We never get to the stage where everything is sorted. In jobs, relationships, goals and personal needs: it’s a constant effort of jumping from one challenge to another. There is no perfect time, just the imperfect now. All we can do is adapt as best as possible.

There are no miracles.

When a piece of code doesn’t work right, the last thing you can do is to reach to a prayer book to answer the problem. Coding doesn’t respond to miracles, only to hard work. There’s always a logical answer embedded there somewhere, and an “aw shucks” moment when you finally figure it out.

In life, there’s a huge amount of fuzzy, magical thinking around which purports to have mystical answers to life’s deepest questions. But in the end, nature trumps such wishful thinking. Many things work in very complex ways, but deep down, it’s just natural laws at work. No matter how much we wish otherwise, there are no short-cuts to figuring out the great problems of life.

You get to practice some important life skills

Coding can involve a lot of playing around and trying things out just for the sake of it. If you are doing it against any kind of deadline, however, or if you need to write code for someone else, you have to learn to organise yourself. Coding generally involves a lot of thinking, writing, testing and improving. If other people are involved you will need to carefully consider how long these different phases are going to take, and give people updates if things don’t go according to plan. This, in essence, is basic project management.

Of all the competencies required by companies nowadays, managing projects is one of the most important skills you can learn. Over time, coding helps you to understand how long a task should take and how to regularly check your progress. You also gain experience in learning how to work with people and what’s involved in giving them just what they want. It’s hard work sometimes. Through it, you learn persistence, tenacity and negotiation – skills that are important throughout your adult career.

Coding is all around us.

The more we learn about this wonderful universe, the more we learn that very similar processes are everywhere around us. Our DNA is a type of elaborate computer program that shows how basic chemicals can be turned into the stuff of life. The way our brains behave and operate is akin to the working of a complex computer system. Evolution itself is an enormous, long term natural coding project where mistakes are punished by extinction, while adaptability is generously rewarded – it’s the biggest experiment in trial and error the world has ever seen.

Coding has helped to open the world up to us; enabling us to understand the universe in ways that our ancestors could never have imagined. Looking at the complexity of nature in terms of different algorithms has allowed us to make sense of it all. From coding you get an insight into how things hang together. It’s through coding we will solve the great challenges of this century.