the accidental businessman


You need math to program, and that's a good thing

July 15 2014 · Permalink

Note: I wrote this post back in November of 2012, but it disappeared when I moved away from Wordpress. The topic keeps popping up, however, so I thought I’d republish it here.

It’s not uncommon—in fact, it hasn’t been uncommon for many years—to come across two kinds of archetypal articles or blog posts about the difficulty of learning to develop software: The “No Math and Everybody,” and the “Math, and Specials.” We’ll call them M&E and M&S for short.

The M&E posts claim that there is no need to be good at math in order to be a good developer, usually citing a personal backstory based on receiving average or poor marks in math subjects at school and still managing to make a good (or excellent) career out of writing software.

The M&S posts, on the other hand, claim that math is a fundamental prerequisite of programming, and that, therefore “software development isn’t for everyone.” You have to be “special” (whatever that means) to be a good developer.

In my ever-so-humble opinion, both these kinds of posts say exactly the same thing: You have to be good at math to be a developer, but probably not in the way you think. And you have to be special, but probably not in the way most people conceive “special.”

The thing is, programming is mathematics, and, therefore, you cannot be good at one without being good at the other. Unfortunately, the way we are taught math in primary and secondary school is not very conductive to programming, resulting in a large number of people who never even try their hand at software development because “they don’t get math,” and a significant minority who find out that, despite their unremarkable grades, they can write code easily and successfully.

In all fairness, math is a hard subject to teach, because even the simplest of ideas exist at the tail end of concepts that require a disproportionate amount of maturity to understand.

For an example of this, you need look no further than the humble addition. In grade school, we are taught that two plus two equals four. This can be easily demonstrated by taking two groups of two objects and putting them together—a method that can probably be used to some effect up to a sum of a few dozens, or maybe a hundred or so objects, before it falls apart completely. A more rigorous treatment requires an understanding of fairly advanced concepts, like set theory, that according to traditional pedagogical thinking, are deemed to be well beyond a young child’s ability to comprehend, and not of much practical use in everyday life.

Alas, one doesn’t get far in this world if he or she can only add numbers up to one hundred. Thus, teachers are forced to teach arithmetic as what amounts to a series of magic tricks. Students know that adding in a particular way, carrying ones, and so on, yields a correct result because someone has told them to, but they have no idea why—thus setting the stage for a lifelong lack of understanding of conceptual mathematics.

Even something as simple as positional notation cannot really be explained without understanding exponentiation and logarithms. Thus, most people only ever learn that the right-most number represents the units, followed by the tens, the hundreds, and so forth. Put someone who has only learned positional representation this way in front of a hexadecimal number, and they’ll think they’re staring at a secret communiqué from Moscow.

Please understand that I’m not judging this approach to teaching here. I have my opinion of it—and it’s not favourable—but that’s fodder for another article. My point is simply that primary and secondary schools teach students math from a purely practical perspective, leaving little to no time to learn the actual theory behind it.

And then, there is university, where math is suddenly taught only as theory. The pedagogical disconnection is almost complete: One moment, you’re in your senior year of high school, performing endless calculations of integrals and derivatives (math’s equivalent of waterboarding). The next, you’re staring at a tertiary-level book written in a language that is completely alien—you might as well be reading a Klingon epic whose author proudly proclaims that today is a good day to ρ(∂x/∂y + v · ∇v) = -∇p + ∇ · ;T + f.

It’s not entirely surprising that plenty of people suddenly find themselves struggling with this very foreign way of looking at mathematical concepts, and continue to have trouble with them throughout their post-secondary studies. Unless you are highly motivated or you luck into a professor who is really dedicated to teaching instead of competing for grant money, learning math this way after twelve years of getting by on magic tricks is hard.

And this brings us to programming. You can learn to program without “being good at math,” if by “being good at math” you mean having gotten good grades in school. But programming is based on a number of rigorously-proven mathematical concepts, and you will be doing math whether you choose to believe it or not.

Sure, you can learn to program by rote: Anyone can teach you what a for loop or an if-then-else statements do—in fact, most programming courses are (unfortunately) predicated on this very approach. Or you can learn the mathematical concepts behind practical programming constructs like control structures, and actually understand what you’re doing. Essentially, math is the ultimate design pattern: It takes something that you can grasp intuitively and formalizes it so that you can apply it appropriately and consistently.

Why make a big deal about statements that “programming isn’t math?” Because downplaying math’s importance solves the wrong problem. The math that you need to become a good programmer is not complicated; you can probably get all you need from a couple of popularized books on Boolean logic and set theory, both of which can be understood at a high school level. You can follow those up with books (or courses) on programming techniques. Pretty soon, you will notice that a pattern of learning and experience begins to form, without any need to worry about integrals or derivatives ever again (well, almost).

Learning math this way is fun, and much less complicated than most people ever discover; it has nothing to do with grades, and very little to do with school. You need to be “special” in order to be good at it because it takes perseverance and experience, much like everything else in life, but that’s about it.

Programmers are made, not born.

You should follow me on Twitter, and discuss this on Hacker News.

A humble wishlist for Apple developer relations improvements

June 9 2014 · Permalink

Looking for a Node developer

March 10 2014 · Permalink

I am not an introvert. I am just busy.

March 5 2014 · Permalink

Allow your Node.js workers to die honourably with Seppuku

August 8 2013 · Permalink

Smug Languages

August 7 2013 · Permalink

Living with the CAP theorem: a Kobayashi Maru approach

July 15 2013 · Permalink

Going Static

July 13 2013 · Permalink

Conflicting feelings

July 10 2013 · Permalink

The 7-bit Internet

July 9 2013 · Permalink