Learning to Program with C

When it comes to teaching programming, I only have one successful pupil: myself. So far be it from me to tell anyone how best to learn to code — I can only tell you what worked for me. That said, of all the things I did, by far the most valuable was learning to program in C.

Specifically, I read The C Programming Language (2e) cover to cover and completed all of the exercises. The "K&R" book assumes the reader is already a professional systems programmer, but at the time I barely understood what an operating system does, so working through it was enormously challenging. Yet it was profoundly educational, because I learned not only C, but also the fundamentals of computing, and how to apply them practically.

I had actually tried to move from BASIC to C starting in middle school, to no avail. Several years later, I finally succeeded when I discovered K&R — a success which I attribute to its unique qualities. The writing is exceptionally clear and terrifically dense, and though I struggled through its 279 pages, the compact size also lends itself to repeated study. And if Jeff Watts has taught me anything, it is that repetition is the key to developing the ability to execute intuitively, which is the highest level of competence — or as he puts it, "repetition is the mother of skill."

C and C++ (its descendant) are still the lingua franca of systems programming, so C is therefore worth knowing if you want to work in that space. Moreover, C is closely modeled on a type of hardware architecture which persists as the standard all these decades later. And no matter how high-level you work, your code ultimately has to run on a low-level machine (probably with an operating system written in C). So I have personally found it enormously useful to understand these fundamentals, much like how physicians benefit from knowing the essentials of human anatomy, no matter their specialty.

The exercises were, of course, incredibly challenging; writing a custom malloc() routine was a particularly memorable gauntlet. I saved my solutions, so if you get stuck on any one assignment, you can try studying my approach. Then wait a week or two and attempt it again on your own. After several repetitions, it will start to become second nature.

So, will going through this process — call it "The K&R Challenge" — make you a great programmer? Well, there are no guarantees in this life. But I suspect that those who find the challenge invigorating, rise to the occasion, and persist until success — they have the best odds anyone could hope for. Godspeed!