A picture of a mathematical proof in CS.

Who's afraid of the big bad Math

written on June 5, 2023

categories: computer-science

tags: math, teaching

"Do you need to know math to learn programming?"

That's a question that comes up extremely often by people — especially people in high school or younger — that are thinking about going into computer stuff in general, ranging from programming as a hobby (PaaH?) to pursuing a fully-fledged CS degree in university. In my experience, this is correctly interpreted as "I frickin hate math" and people understandably rush to say that it has nothing to do with math and that you can totally go into CS in any way without caring about or liking math.

The thing is, this answer has always bugged me, because first and foremost it's not true, and second because it treats the symptom and not the root cause.

Now, don't get me wrong; my entire point in this post assumes that you can have a nuanced conversation with the person that asked the question. If you have to give a single-word answer, I'd agree that probably the best thing you can do is reassure them and not drive them away because of how they (currently) view math.

If you do have the time and context needed for a more nuanced discussion however, I think it's worth it to try to offer a more complete explanation of what's going on. I think the conversation is probably going to go one of two very broad ways, based on what the person is actually trying to get into.

Getting into a CS degree

There's not really a soft way to put it; in this case the default answer to the question is simply false. CS definitely is math, or if you have some purist definition of CS that you will defend to the death, it at least did start out as a branch of math and is still heavily based on math.

So, the fact of the matter is that getting into a CS degree while hating math is not gonna be fun. But! I personally absolutely started my computer engineering degree with very little appreciation for math, and I'm sure I'm far from being the only one. So what gives?

This is kind of what I was referring to by "treat the root cause, not the symptom": the problem here is not that people fresh out of high school (to give an example) hate math, it's that they hate the math they've seen so far, and actually most likely how they learned it1. I think it's actually very important to explain to people that the math they've seen is but a tiny fragment of what there is to do in the entire field of study, and frankly it's not a fragment that's necessarily extremely popular. The bottom line is, yes, you will do (quite a bit of) math in your CS degree, but it's not at all like the math you've seen so far. In my experience, the more you progress, the more the math becomes abstract and interesting, although that does come down to personal taste.

Getting into programming as a hobby

If computer stuff is a potential hobby for you, meaning that you want to learn a bit of programming to make a site or a simple game in an engine or something, then I agree that the default answer given to the question is more valid in this case.

However, I would argue that you should give math a try anyway! If you're into programming, chances are you like solving puzzles, and that's basically what the math you'll come across is. Again, math is a vast domain of study with extremely different-looking parts, and you shouldn't knock it just because you've tried a tiny fraction of it that just didn't click for you. Plus, you're most likely going to need math for other purposes; the entire field of game development is full of math.

But I actually, seriously hate math

What to do if you viscerally despise math? I'd say, take a few steps back and try to reconsider the situation.

I feel like most people — myself definitely included — hated math fresh out of high school because a bunch of stuff flew right over their heads, and that made them feel dumb. Another reason is that math taught in high school (or before) feels extremely tedious and almost pointless, just like learning how to use a hammer by hammering down a bunch of nails to a piece of scrap wood feels pointless even though it isn't.

As a person online once put it very accurately: you can be very slow at math, so long as you're correct. It simply takes many (probably most) people a long time to grasp new concepts, and they often need to view them from multiple different angles for them to click. This should really come as a surprise to no one, yet it's somehow a common idea that someone is "bad at math" if they don't immediately master everything that's served to them in high school math class.

What you need to understand is that math that you'll come across when it comes to computer stuff (and actually, most math in general) is not at all like the computational, "solve this equation" stuff that probably forms the majority of your current relationship with math. That has nothing to do with the math you get to use in CS, and actually I have multiple friends (who are finshing their Masters or are well into their PhDs in math) that were never good in that sort of tedious, computational part of math. My experience with math in CS feels more like arguing to defend a point. To give an example: I remember having to write a proof about why the lower bound for the number of comparisons needed in order to find the k-th largest element of a set A of size n is equal to
n - k + lg(n choose (k - 1)). That might sound complicated or weird but it's basically just used to understand what the faster algorithm that can find the k-th largest element in a list is; the proof was actually just a lot of explaining using words and a few symbols when necessary2.

Does it require a lot of rigor? Yes. Is it hard? Often, sure. But it still does feel more like you're trying to convince someone about something, crafting your arguments very carefully and precisely, rather than filling pages and pages with tedious calculations just to get a random number that doesn't mean anything to you.

So, I guess that my answer/hot take is:

  1. Yes, there is math involved in computer stuff, but it's the fun kind.
  2. You're actually probably not that bad at math (and almost certainly not as bad as you think).

  1. Why they didn't like learning it, or whose fault it is, is a discussion for another day. 

  2. You can definitely use only symbols and no words to write proofs like that, I just personally think they're unreadable. 


< Google foobar, part vi: growing cells