In Defense of Learning Code the Hard Way

At least relatively speaking.

It's the new year, which means many of us are making resolutions to be better, healthier, less-bad, or just generally more valuable human beings.

One popular resolution is (again) learning to code. With an ever-multiplying field of e-learning websites, web dev bootcamps, and other for-profit entities invested in the teaching of coding, this is a continuous, relentless year-round push, but the New Year is a magic time for the cultivation of casual learners. Learn to code: It's easy!

From edX: "Become the genius that designs, controls and powers the digital devices, websites, mobile apps and more that we interact with every day." It's tempting, right?

I've taken several computer science and programming courses from edX, usually to brush up on something or to supplement a college class (and rarely to completion), and they were pretty great. I've also taken courses from Coursera, Udacity, Stanford's Lagunita (based on the edX platform), and MIT OpenCourseWare (which is more of a passive open-ed platform). Those are great too and all can be had for the low price of $0 (though you can often pay money for upgrades, like certificates and "nanodegrees").

So, it's all right there for the taking. Should you do it? Should you learn to code?

No. At least no not in the usual sense of "learning to code." You should learn to code eventually and sooner rather than later, but the wrong course to start your coding education with is the introductory JavaScript course that will teach you some basics of syntax and how to use that syntax to do a few neat things to websites.

There are a lot of these courses out there, and if you were to Google "learn to code" right now that's most of what would be returned: Intro to JavaScript.

Don't take that class. If you want to make websites, learn JavaScript eventually, but don't start with it. Once you have some foundation in how code works, in how programming languages behave and interact with computers and the web, JS will be nothing. You might even choose to avoid it and front-end web development altogether.

The difference between learning to code and learning about code is obviously pretty fuzzy. You need to use code to learn about it, but there are better and worse ways of doing this. The better ways are going to more difficult, less immediately applicable, and they are going to take more time. I'm sorry, but it will be worth it in the end.

I learned to program in C at a community college and I wouldn't have done it any other way. As is common in undergraduate computer science programs, this introduction was spread across two consecutive courses in two consecutive academic quarters. I had little interest in computer science at the start—I was chasing an electrical engineering degree and the CS courses were requirements—but I wound up hooked, changing my track from EE to computer science and eventually transferring to a four-year school and, eventually, getting accepted into a computer science graduate program.

If you want to make websites, learn JavaScript eventually, but don't start with it.

I wasn't hooked on programming language syntax or manipulating programming libraries and frameworks. I wasn't hooked on jQuery or Bootstrap. I was hooked on problem solving and algorithms. This is a thing unique to programming: the immediate, nearly continuous rush of problem solving. To me, programming feels like solving puzzles (or, rather, it is solving puzzles), or a great boss fight in a video game. Eventually, you just start thinking a certain way to the point that it even invades your dreams. That's a weird one: dreaming about algorithms.

To learn about coding, to understand coding, you should learn a language like C—ideally C itself, but C++, Java, Python, or another common general-purpose programming language would be chill too. The point is to learn programming as it is nakedly, minus as much gunk and fluff that can possibly be removed from the experience.

That's what C is—a close layer affixed atop physical computing hardware, which still matters. You can break C pretty easily, particularly when it comes to managing computer memory. It's not foolproof by any means and many C-like programming languages exist expressly to avoid the errors made possible by C, such as buffer overruns.

The thing is that this stuff doesn't go away if you're programming with a more user-friendly language, it's more just hidden. Eventually, as coding becomes less about learning and more about doing, that will be pretty helpful. But low-level things like memory and data types are fundamental to programming machines. (With the advance of the Internet of Things and the resource-limited computers behind it, dealing with memory and optimizing code will remain important in many practical senses, but that's another post.)

The point is mostly that all other things in code are built from fundamental constructs: control structures, looping/repetition mechanisms, data structures. Even if your plans are limited to making the dopiest template websites, you should probably understand how to put together a linked list (a construct that doesn't exist in JavaScript because JavaScript eschews one of the most fundamental things in programming: pointers, or variables that point to specific locations in a computer's memory).

To restate, you should learn first the ideas behind building things with code. Know that they're there. It doesn't have to be C; C just happens to be the canonical example of what I'm going for here. You could build a giant ass bridge with prefabricated materials and a set of detailed instructions without understanding a thing about the physics behind what makes a bridge not collapse, but I'm not sure I want to drive over that bridge.

So, my general advice is to take an introduction to computer science course, from edX or wherever. It will probably be based on Python, which is fine (Python is a great language). You won't wind up with a cool website at the end. More likely, you'll have a command line program that can check if a number is prime or not. Something dry like that. Do that first and you'll be a thousand times better off in whatever code/programming endeavor you choose to pursue after. Just do it the hard way, if only at the beginning.