A combination of deliberate programming practice and hacking on projects is the best way to learn programming. Many programmers choose to focus solely on hacking and Google their way through problems, but this is an inefficient learning approach when it is not coupled with deliberate practice.
Deliberate practice involves reading books, taking notes, studying the notes, testing yourself on the new material, and applying the new knowledge with practical applications. The notes and tests need to be periodically revisited to make sure the knowledge is retained. It is important to keep drilling the material every few months so it stays fresh – it is much easier to maintain knowledge than lose it and learn it again later.
Deliberate programming practice is similar to the deliberate practice of elite athletes. Professional basketball players grow up playing pickup games in their neighborhood and play for school and travel teams, but they also spend a significant amount of time training. They study film to learn about game strategy, lift weights to gain explosive strength, and practice shooting to focus on form. An athlete cannot perform at an elite level if they only play pickup games for training.
Programmers can practice deliberately by reading books, studying theory, and drilling important concepts. Without regular practice, programmers will partially forget what they know, Google frequently, and consequently interrupt their flow. Too much time will be spent wading in the shallows instead of applying knowledge.
I’ve lost most of the knowledge I acquired from books, college, and the CFA program because the content was organized in notebooks and index cards and I lost track of it. My focus was on learning the information for tests, not for storing it in a suitable format for frequent reflection and life-retention. I’ve learned from this mistake and started CodeQuizzes to organize my programming knowledge, so I can test myself regularly.
A programmer that hacks frequently and is naturally talented will do well without any deliberate practice, but will not achieve their full potential. A disciplined and focused study routine involving frequent reflection on material that has already been covered and constant reading to learn new material is how to program at an elite level. The hacker that gets by on natural talent alone is like the neighborhood basketball player that never lifts weights – a competitive player that did not achieve their potential.