Stop making learning to code easier

If you look around on the internet for resources to learn coding, you’ll notice a trend. Most resources don’t explicitly say that learning to code is easy but somehow they give that impression.

“Anyone can learn to code.”

It’s understandable to try to present coding this way. And of course, here at Grok Learning, we’re guilty of this too:

“Learning to code has never been so easy or fun!” — Grok Learning

There’s already a lot of discussion out there on why students should learn to code. It develops problem solving and thinking skills, it prepares students for a lifetime of working with technology and enables them to better understand the world of software they use every day.

Until recently, coding hasn’t usually been part of a mandatory school curriculum (but now in Australia it is!). Introducing both adults and school students to coding has required them to choose to start studying it. It had to be in their own time, an extracurricular activity or as an elective unit of study. In order to entice more people into coding, educators and online coding resources started to promise big results with very little time and effort.

“You’ll start off learning to build simple apps and websites, but quickly progress to building real-world applications you can show-off to friends and future employers.”

Once the students are in you don’t want to lose them. Every educator has experienced that moment where they lost a student. The student will slump their shoulders, their eyes glaze over, they start distracting themselves to avoid the problem… in short they give up. At some point they found something hard and the friendly words “anyone can learn to code” start to feel like “I must not be very smart if I find this hard”.

Online learn-to-code resources in particular try to smooth out all the barriers to avoid losing students like this. They try to make everything easier by holding the student’s hand and guiding them carefully along the right path. There are many online tutorials which lead a student through the creation of a specific game or app going step-by-step, providing all the necessary code in digestible pieces. At first this feels great! The student is making progress, building something cool and succeeding at it.

Unfortunately, it’s impossible to avoid the real difficulties of coding if you want to build your own programs. Even the best, most experienced coders will regularly find themselves staring at some code, completely dumbfounded by how their program could possibly be causing the computer to do what it’s apparently doing.

Even the most experienced developers can get stuck for hours on a single problem.

It can still be frustrating sometimes, but an experienced coder will have learned techniques to work through this and figure out what the problem is. They will do things like add extra lines of code to display what each step of the program is doing. They’ll start making theories, testing those theories by modifying the code and checking if their assumptions are correct. They’ll find online resources or ask people for explanations of the parts they’re not sure about or for new theories to test. Most of all, they learn not to give up because they’re used to encountering problems like this.

For a newbie coder who hasn’t learned those techniques yet, a blank text editor or an error message is daunting. Sometimes a student’s first instinct is that they don’t know the “correct” answer so they need to look it up. With some encouragement they’ll try something but if it doesn’t work correctly they’ll assume their program is “wrong” and again, they need someone to tell them the “correct” answer.

Unfortunately, if they are too often provided with the “correct” answer, they miss out on developing the necessary skills of building up a program in steps and testing their solution as they go. They miss out on the whole process of debugging; the process of creating theories for what the program is doing, testing those theories and modifying the program until it works.

When students are taken by the hand, and lead carefully through step-by-step coding instructions it can look like they’re making a lot of progress very quickly. The students are building some cool programs, building their confidence and feeling good about coding. This is an illusion, one that is painfully destroyed when reality hits. This happens when students start to write new programs from scratch, or fix a broken program without steps to guide them to the solution. The problems they’re trying to solve are already complex, but they have not yet developed the techniques to solve them.

The Cliff of Confusion and the Desert of Despair

Erik Trautman wrote a fantastic blog post on why learning to code is so damn hard with vivid imagery to describe this process. The first time falling out of the safe world of hand-holding coding resources is called the “Cliff of Confusion” shortly followed by the “Desert of Despair”.

Have a look at the comments section. There’s a lively debate between those who experienced the cliff and desert and those who did not (or don’t remember it). One of the key differences is how they approached learning to code at the start. Those who started with easy hand-holding coding resources, ended up in the cliff of confusion when they ventured outside and started writing their own programs. On the other side of the debate are the coders who struggled through writing programs from scratch at the very beginning. They never experienced that sudden increase in difficulty because they learned the necessary skills along the way, gradually building them up.

Avoiding the Cliff

In order to avoid this sudden increase in difficulty, students need to build up their debugging and problem solving skills at the start. This means learning it at the same time as learning the basics of syntax, control structures and other programming concepts. The process of attempting, failing and correcting is the fastest and most effective way to learn how to code.

1. Teach debugging from the beginning

Avoid resources where the students are hand-held through the process of writing code. Examples are good, but they should not too-closely match the code the students need to write themselves. We’ve worked hard to scaffold this process in Grok Learning as much as possible, while still requiring the students to write programs from scratch and learn effectively from the very beginning.

2. Set expectations

Emphasise that coding will involve training their brains to think in a new way, and they’ll spend a lot of time working on a program, continually changing it until it works. Make sure that they know that this struggle is an important part of the learning process. Talk to them about what to do when they get stuck. Check out this list of debugging tips for some suggestions.

3. Celebrate struggle and learning rather than achievement

The research on encouraging Growth Mindsets in education is particularly relevant to coding. Like maths, students often mistakenly think that coding is ‘natural’ to some and not others. It’s important to celebrate the learning process by focusing on students who got stuck on a problem and struggled hard to get through it — even if they didn’t actually get to the end. Try building a class collection of interesting problems and identify the strategies used to overcome them.

4. Lead by example

Try showing the class a tricky or confusing problem then go through the whole problem-solving process together— including going down the wrong paths. If you don’t have any tricky examples in mind, don’t worry the students will find some for you, just remember to collect them.

The most important step to take home is to let the students go down the wrong path, figure out that it’s the wrong path and learn to correct it. Here’s the experience of a man who learned to code in 8 weeks:

…do all of the associated exercises until you get them right — without looking at the answers. Struggling through the exercises I kept getting wrong was the best learning experience. I would have learned far less had I just looked at the answers and tried to convince myself that I understood the concepts.

With the right expectations and encouragement, all students can develop the skills they need to work through difficult coding problems. It can feel like it’s the hard way, especially at first when the students are getting over the first hurdles. It’s worth it in the long term though, to gain the skills needed to deconstruct and solve bigger problems in both coding and life.