I had not realized this myself, but now while dealing with students it is getting more than obvious. Even after attending most of the classes they lose their confidence when asked to write code. The main reason that I could dig out was that they were still not comfortable writing code. Whatever code they did write was usually a copy from some book or from the Web or they simply did not write yet. They were banking too much on the theory, or I would say they got so comfortable with theory that writing code started making them uncomfortable.
This affects their ability to understand the concepts. Just knowing the concepts is not enough, it is important to see them applied to solve problems. And that cannot happen till you see code in action. Writing code introduces a lot of practical disciplinary things, like including header files or using namespace or why classes should be written in header files. Most importantly writing code can help you understand why certain code works like that. You start coming up with your own abstractions, your own text, your own analogies that help you understand better. And if you do not write your first program, you get stuck with whatever someone else is talking about.
Mind you, the first program is not the usual Hello World program, which does nothing more than help you execute your first code. The first program should have a problem statement, it should have specifications, restrictions, validations and intended use. This first program will take you across the biggest block – hesitation or inhibitions about starting to write code, whether it is a function, class or a program.
Not only limited to students, this can help software developers too who are learning new programming languages. It was not very straight-forward for me to understand the functional programming techniques after being so deep into the imperative programming way of thinking. However writing programs, original programs, without looking elsewhere for code helped. It did bring up a lot of problems – syntax, appropriate constructs, best practices, everything.
Writing the first program does not help you avoiding mistakes, but it does help you in quickly learning from them.