One of the things I’ve seen new programmers struggle with the most is the error messages they get when attempting to write their first programs. They’ll pay attention to the lessons they’re being taught, do their best to understand the concepts like variables and loops, and then attempt to solve their first problem.

And then the compiler (or maybe the browser) essentially tells them they did it wrong. Often the most diligent students will take this as a personal affront… it’s not just that the compiler is telling them their program is wrong, it’s that the compiler is telling them they’re stupid (this isn’t reality, but this is how it feels).

I think this stems from a lot of the “textbook learning” that students typically encounter. In a textbook students are given an overview of concepts with some example solutions to problems, and then are asked to solve exercises (with answers provided at the back of the book). When students fail to solve a problem, they see it as a lack of understanding that needs to be corrected.

This model of learning does not directly translate to programming. On the one hand, yes, when you get a compiler error it may be a sign that you don’t understand something and there is an opportunity to correct that misunderstanding. On the other hand, experienced expert programmers spend much of their working day correcting compiler errors, because making mistakes (big and small, fundamental or trivial) is part and parcel to programming!

Programming involves the solving of novel problems on a consistent basis, with solutions expressed in a very precise and unforgiving syntax. It’s not like learning Physics 101 where once you understand the equation and how to plug in the numbers you can solve identical problems and over and over without error.

This is why I’m a big advocate of the “live coding” model of teaching programming, where the instructor writes programs in front of the students, including making mistakes and correct them. It is essential that students see this for two reasons:

  1. Making mistakes is normalized for students. If the instructor makes mistakes and is OK with it, then it must be OK for them too.
  2. Students learn from the problem solving process followed by the instructor. When the instructor interprets the error message and applies strategies to solve the problem (e.g. examine the line of code flagged by the compiler, use Google/Stackoverflow), this teaches students how to problem solve using these strategies as well.

I try to leave “mistakes” in my videos for Portfolio Courses for similar reasons… to help learners via adopting new strategies to solve programming errors!