How To Learn Programming in C

The foundational programming language isn’t easy, but there are a billion resources to get you started.

Last weekend I incurred the understandable wrath of many a programmer by suggesting that new coders learn coding "the hard way" via the C programming language rather than the language most of the universe wants them to learn, which is JavaScript. While a lot of readers wrote in to say that I was full of shit, I've also been getting a steady stream of emails asking: How do I learn C?

Read more: Know Your Language: C Rules Everything Around Me

Good question! Given the completely overwhelming glut of online learn-to-code classes, it's not always obvious. I'll try to give some answers below.

Community college

I started studying computer science at Portland Community College. My instructors were enthusiastic, interested in my success (as an individual), and almost all of them came from the software engineering industry. This is where I learned C.

Results may vary, of course, but your local community college is worth investigating. My classes were next to free and were designed to be foundations for later CS learning. I wouldn't have done it any other way.

edX CS50: Introduction to Computer Science

This is Harvard University's Introduction to Computer Science and, in addition to the edX verified certificate ($90), there's a for-credit variation. Looking through the syllabus and reviews, this course isn't fucking around.

Effort-wise, the CS50 packs in nine problem sets with each one requiring 10 to 20 hours of work, and a final project. If that seems like a lot (it shouldn't), it's because the course covers a lot. It starts with C and basic computer science stuff (algorithms, data structures, computer organization), but progresses into more on-the-ground topics like security, web development, and even artificial intelligence.

C isn't the only language taught here either, and by the end you'll have a rough understanding of web and database languages too (HTML, JavaScript, SQL).

Learn code the hard way

So, yes, there is an actual C course that's just called Learn C the Hard Way. It would seem to live up to its name, offering a series of 52 exercises covering a vast field of knowledge from basic stuff like loops and control structures to designing your own TCP/IP client.

It's meant for professionals relearning the C language, programmers experienced in other languages (especially a C-based language like C#), and anyone else who "likes a challenge." There are no cut corners here, and, given that's why we're learning C in the first place, this might be your best bet.

This is from the LCTHW introduction, to give some idea: "Our computer and the Operating System controlling it are the real tricksters. They conspire to hide their true inner workings from you so that you can never really know what is going on. The C programming language's only failing is giving you access to what is really there, and telling you the cold hard raw truth. C gives you the red pill. C pulls the curtain back to show you the wizard. C is truth."


Become a maker

The tiny computers powering the things of the Internet of Things and the clever machines of the Maker movement are largely programmed in C. For example, the "Arduino language" in reality is a more user-friendly wrapper above the C language—an additional layer of abstraction.

Arduino boards and their more utilitarian kin are what have historically been known as embedded systems or real-time systems. Because they come with limited computing resources (especially memory), they rely on carefully optimized software with the capability of directly controlling computing hardware at low-levels. As much abstraction as possible must be peeled away and this is what the C language and the suite of language extensions known as Embedded C offer.

So, build a robot or something. Eventually, you just won't have a choice but to learn C.

Learn Unix

C was invented to implement the Unix operating system in the 1970s and, while C has become a cross-platform force of nature, it remains tightly bound to Unix. C allows engineers under-the-hood operating system access in ways that can add up to very powerful programs. There's really no way to understand Unix (and operating systems generally) without understanding C, and you could probably argue the inverse as well.

There are a billion other ways to learn C, of course, whether it's via other online classes or more self-directed approaches. The C for Dummies book gets a surprising amount of love, while CProgramming.com is both a standard reference and a good storehouse of tutorials. The C Programming Language, often known just as the "K&R," remains the language's bible even four decades after its first publication.

The best way to learn something is to just do it. You can read and watch videos all day and all night but it won't make much difference if you're not down in the shit yourself writing code. This is probably the best advice I can give about learning C or any other language.