Programming Is Not Math

When I learned to program, back when dinosaurs walked the earth and the internet had no cats, there was an idea: if you were good at math, you’d be good at programming. I was great at math as a kid, but perhaps because I didn’t like it much, no one steered me towards programming. I came to it accidentally, in college, when I took an elective programming class because it fit my schedule.

So my first programming language was Fortran, an abbreviation of “Formula Translation.” As you might expect from the name, the projects in the class were exciting things like estimating the area under a curve using rectangles, like you see in the diagram below.

The Riemann Sum.

The Riemann Sum. Thanks to H.J. Keisler.

Doing Riemann sums in Fortran is about as math-oriented an introduction to programming as you can get.

And I loved it. SO MUCH!

That same quarter, I was taking my first Japanese class. Towards the end of the term, when I was getting ready to change my major to computer science because PROGRAMMING FUCK YEAH, I thought briefly about how similar the two classes felt. In both cases, I was coming into a culture I didn’t understand or feel part of. I was learning the mechanics of communicating, while at the same time trying to gain enough cultural knowledge to feel at ease.

But I knew – and everyone knew – that programming was like math. So clearly, I was good at Fortran because I was good at math.

Now, almost twenty years later,

I’ve changed my mind.

It started when I graduated, became a software engineer, and discovered that the vast majority of developer jobs only required middle-school math at the most. I had to keep a bit of math handy to do whiteboard interviews, but once I was on the job, my ability to communicate both with computers and with other humans was much more important.

I figured, at the time, that my jobs were the exceptions. Surely most programming was way more about math. I just, uh,…didn’t see those jobs. Even on the job boards. And my friends didn’t seem to have them, either…but oh well.

Then after I’d been working about ten years, I started teaching new people to program in my free time. I taught Ruby on Rails, which is a web programming framework; people came because they wanted to learn how to make websites. Because of those motivations, the curriculum had virtually no math.

And this is what finally did for it me. The students I saw – all adults – came from a wide range of backgrounds. People with a math background did fine, of course, but people with a heavy language background often did better. I saw this curious effect again when I started working with high schoolers, with a similar curriculum. Bilingual kids often took to programming more easily than monolingual kids.

I thought back to college, to my jobs, to my friends’ jobs, teaching…and I finally figured it out. Programming is not math.

Programming is Language.

Specifically, learning to program is more like learning a new language than it is like doing math problems. And the experience of programming today, in industry, is more about language than it is about math.

And my next thought, of course, was why doesn’t anyone else think this? Why do we still have this idea that math skills indicate programming potential, while language skills mean you should go into poli sci?

Well, when I feel out of my depth, I usually start by looking for “official” opinions. So I looked for relevant academic research.

WTF ACADEMIA

I found absolutely none, which is pretty flabbergasting. I found a lot of opinions, both from computer science educators, and from people in industry. Perhaps within academia, the link between math and programming is considered such an obvious truth that it isn’t worth confirming with research.

It seems more likely, though, that this research exists, but not under the search terms I tried. Please let me know if you are aware of relevant papers.

In the meantime, if we can’t have data, we can at least examine the conversations people have on this topic. Here are some things people often say when asserting that people must be good at math to be good developers.

Generally, they fall into three categories:

1. “You need to know math to be a good programmer.”
2. “You need to learn math to get the skills you need for programming.”
3. “Plenty of programming is still math!”

Let’s look at them one at a time.

1. You need to know math…

1A. …because computer science comes from math.

This is true. Academically speaking, most computer science departments trace their lineage to the mathematics department. Many computer science degrees are still very math-heavy. Mine certainly was.

However, as many other people have noted, computer science is not programming. At most academic CS schools, the explicit intent is that students learn programming as a byproduct of learning CS. Programming itself is seen as rather pedestrian, a sort of exercise left to the reader.

For actual developer jobs, by contrast, the two main skills you need these days are programming and communication. So while CS still does have strong ties to math, the ties between CS and programming are more tenuous. You might be able to say that math skills are required for computer science success, but you can’t necessarily say that they’re required for developer success.

1B. …because without a mathematical foundation, you’ll have only a surface understanding of programming.

A common variation on this: without a CS degree, you can’t build anything substantial. Which, ha ha! Don’t tell the venture capitalists! They’re down there on Sand Hill Road giving actual money to hundreds of people building software projects without any formal qualifications whatsoever. In fact, they do it so often that the college-dropout-turned-genius-programmer is our primary Silicon Valley archetype of success. And monetarily, their strategy seems be to working out for them, if the fleets of Teslas on 280 are any indication.

Back here in the real world, I have found little connection between a person’s formal qualifications and the depth of their understanding. As an example, consider whiteboard interview staple big-O notation.

If you took a dynamic methods class in school, you know that big-O notation is pretty much meaningless in the real world. Which is to say, it doesn’t matter how an algorithm operates on an arbitrary set of data. The only thing that matters is how it operates on your set of data. An algorithm that is O(n**2) for arbitrary data may actually be constant time (meaning O(1)) on your particular data, and thus faster than an algorithm that is O(nlogn) no matter what data you give it.

There are some interesting mathematical ways to model this, but weirdly enough, the people with CS degrees conducting whiteboard interviews never seem to be too interested. Go figure.

So, if you don’t actually need to know math to be a successful developer, perhaps instead the very act of learning it primes you to think the right way?…

2. You need to learn math…

2A. …because it teaches abstract problem solving, which you need to be good at programming.

Abstract thinking is absolutely a skill that every developer needs to hone. In fact, some people say that finding the right level of abstraction for a concept in your code is the root of all hard problems in software.

It is also quite true that you can learn abstract thinking by studying math. At last year’s GoGaRuCo conference, Daniela Wellisz, a developer with a background in math, did a fascinating talk on how programming is similar to doing proofs in math. I recommend watching it if you’re interested in the topic.

However, just because you can learn abstract thinking via mathematics doesn’t mean there is no other way. Learning a new human language is another way to develop that skill. Coming to understand concepts that are literally impossible to express in your native language is pretty damn abstract. When we learn a second language, the way we re-organize concepts based on a higher level of abstraction is structurally quite similar to how we re-organize concepts when we learn to think mathematically.

So while math is one way to learn to think about abstraction, it is not the only way.

2B. …because programming based on the mathematical concepts of logic.

Indeed, programming is often concerned with logic. But the same logical concepts are embedded in our human languages. Math is just a formalization of the concepts we use every day when we construct sentences and communicate with other humans. The best writers and speakers understand that, and can construct logical statements in human language that are easy for other people to evaluate. Sometimes they even change people’s minds about things.

Mathematical logic is a notation for concepts we already know, and it is the concepts – rather than the notations – that are important.

So if you don’t need to know math to be a developer, and you don’t need to learn math to be good at development…wait! But some jobs still do!

3. My developer job uses plenty of math!

Of course people still use programming to do math. But programming itself no longer is math.

Even in non-math-oriented languages, there are some applications where math will be useful. And then of course there are whole languages oriented around math, such as Fortran, as I mentioned before, and Haskell, a largely academic language now finding favor among some industry developers.

But these are the exceptions that prove the rule. If a small and shrinking set of programming applications require math, so much so that we cordon you off into your own language to do it, then it’s pretty clear that heavy math is, these days, a minor specialization.

And even if you are writing code to do math-y things, you’re probably not very good at it unless you’re also good at language. The best developers today work on teams, and they do well IFF they know how to communicate – via their code, and directly with other people. As one of my favorite programming books once said, “programs must be written for people to read, and only incidentally for machines to execute.”

The long view

If programming is so similar to language, why haven’t we – developers – already made this mental adjustment? Why does the idea that “if you’re good at math, you’ll be good at programming” persist so strongly?

When programming was just getting started, early in the last century, we used it to solve highly mathematical problems like calculating missile trajectories and decrypting secret messages. At that point, you had to be good at math to even approach programming. Tools, such as programming languages, were designed specifically to solve mathematical problems, because those were the ones we thought it was worth spending money on. Computers were for doing math.

Over time, due to lots of different factors, our societal conception of what computers are for has evolved. When considering this question, these days we think in higher-level concepts such as solving a problem, making some tedious thing more convenient, and/or making money. These higher-level goals sometimes include mathematical subgoals, but also include things like ease of use, connectivity, and interface — problems that can basically be summed up as “messy humans and their relationships to other messy humans.”

So as a result, while programming is still applied to some mathematical problems, in our modern world it is more frequently applied to other, messier types of problems. The shift happened pretty quickly – it started gathering steam in earnest in the 90s. And today – only 20 years later – we find ourselves with math-oriented programming jobs firmly in the minority.

It makes sense that slow-moving academia hasn’t caught up yet. And the programmers who today are the senior developers, the old guard, came of age when this wasn’t yet true. So of course they think the path to success looks like theirs.

Don’t Panic

You can still be successful if you walk the traditional path. If you’re good at math, you’ll probably still be good at programming.

But the rapid evolution of our industry means that math skills are no longer the only indicator of potential developer skill. In fact, they’re probably a weaker indicator than they’ve ever been, given where the industry’s going. So please, guidance counselors: send us the ones who love language. We’ll give them the tools to change the world.

66 comments to Programming Is Not Math

  • Yawar

    I think every mathematician, and a lot of programmers, would first ask you to define your terms :-)

    What do you mean by ‘programming’? And what do you mean by ‘math’?

    By ‘math’, do you mean arithmetic, geometry, and calculus that’s usually taught upto US AP high school level? Then yeah, a lot of programming isn’t about that. (Unless you’re a graphics programmer, I guess.) Or do you mean analysing structures, patterns, and algorithms? Then no, that’s the kind of math that’s mostly used in programming.

    By programming, do you mean learning and using the symbols and syntax conventions of a programming language? Then yeah, sure. Programming is a lot like learning and using a human language. Or do you mean formulating and analysing abstract ideas, and expressing them as designs or patterns that can then be implemented using a programming language? Then no, that’s definitely math.

    (Set theory! Wow.)

  • I have some agreements and disagreements with this blog. Firstly, let me state that I feel into computers FROM my love of mathematics. It seemed to be a perfect marriage, and I do lament the lack of mathematical involvement in many of the projects I get paid for today.

    Ultimately, mathematics is about patterns. Finding them and proving them and using them. From this perspective, programming IS mathematics, because you have to do precisely that.

    Having said that, you may not need specific areas of mathematics like vectors or calculus to do many programming tasks, but you WILL need logic, which is math. Data structures, databases, etc. involve forms of mathematics, though one may not normally think of them that way.

    Human languages do have points of abstraction, but they also are very imprecise and fuzzy. Mathematics can be and usually is much more precise than human languages, and yet also deal with abstraction. Computer languages are a marriage of both some aspects of human language and some aspects of formal mathematics, along with other elements relating to the nature of computers. In many respects, it is off in its own space or category. And is hugely variant. Fortran, Lisp, Ruby, and C++, along with Haskell and Erlang, may be seen as vast areas of representation as they not only represent different ways to express problem descriptions, but entirely different paradigms.

    I will wrap this up by stating that, while you can sneak by with programming without getting into some of what is traditionally regarded as mathematics, you are better served to doing the math. What maths you need depends largely on what problems you wish to tackle. If you are looking to do climate simulations, you are of course will be heavy on the differential equations. If you are into doing data analytics, you of course are going to need statistics. If you are doing games and graphics, you of course are going to need vector and matrix math, as well as some calculus and probably some statistics.

    If, on the other hand, you are just doing basic websites, you can squeak by with nothing more than basic algebra.

    It all depends. And the broader ranges of math you know, the broader ranges of problems you will be able to tackle in the programming paradigms.

  • h

    Math is a language.

  • Marvin Gale

    It must be the case that at least half of you that agree with this article have failed at the math core requirements of your respective majors (or did not have to take them at all).

  • Sarah, I’ve already read your article twice and I still want more. Excellent!
    I am a computer science student at Unicamp (Brazil/São Paulo/Campinas) and I really would like to share your text with my colleagues – can I translate it in my website (with original reference)? Also, I think it’s important to say that the CS department at my University just opened programming classes to Linguistics (and Literature) department, supporting your main idea in this article. I couldn’t agree more 😀

  • Sandy Harris

    You wrote “Please let me know if you are aware of relevant papers.”

    The one that leaps to my mind is Dijkstra’s letter about painful truths in computer science.
    http://www.cs.virginia.edu/~evans/cs655/readings/ewd498.html

    Among his points:

    Programming is one of the most difficult branches of applied mathematics; the poorer mathematicians had better remain pure mathematicians.

    The easiest machine applications are the technical/scientific computations.

    Besides a mathematical inclination, an exceptionally good mastery of one’s native tongue is the most vital asset of a competent programmer.

  • Daniel Garcia

    “Any fool can write code that a computer can understand. Good programmers write code that humans can understand.” – Martin Fowler.
    Have you find another disciplines that help with programming besides of languages?

  • Thank you, Sarah!

    I LOVE technology, but I can’t do enough math to find my way out of a paper bag. I have a Ph.D. in English, though!

    I still can’t program, though. Why? Because EVERYONE STILL USES MATH TO TEACH PROGRAMMING! ARGH!!

    I took a MOOC that was supposed to teach me to program, and I had to drop out after the first lesson because we had to program the computer to do a complex math problem that I couldn’t figure out. I could do the programming up until then–but I couldn’t do the math.

    Sigh.

    So, here’s an idea for your next blog: “Why can’t we teach programming without math??”

    Great article, by the way!! Loved it!

    Michelle

  • Chad Dattilio

    YES YES YES. I’ve been floating this idea by my dev friends for a while now, nice to see someone else confirming. After doing programming for many years it occurred to me that what I was doing was more akin to creative writing than math problems. We probably should emphasize two different career tracks… right now basically you take CS (with heavy math and algorithms), then go out and get a job coding websites. We need to keep the CS track for those wanting to dig deep but then have a software engineering track that is more real-world practical (javascript (and frameworks), CSS, responsive design techniques, NoSQL, Node.js, etc). These folks wouldn’t have to take Automata Theory.

  • Whether or not you need to know Automata Theory depends largely on the complexity of the task your are undertaking. If you are handling situations where there are complicated state transitions and the like, yep, you are going to need to know it and how to create state machines. Same deal if you are creating a sophisticated UI, complex rules in business logic, or even the process of making a credit card purchase.

  • Truth is I don’t like maths I don’t know why people keep saying “to be a good programmer, you must love maths” I may not be the best programmer, but I know am up to the task & improving and I also know that I hate maths!!!

  • Mark S.

    I have worked my entire career in computer programming and related areas such as software design, system administration, and project management.

    I have *never* needed to compute the volume of a solid of rotation. In fact, I have never used any calculus at all. Any time the software needed to do any serious math, there was always an expert in the domain knowledge to tell me what to do.

    When I was working on experiements in basic physics, there was a PI (Principal Investigator), a couple post-docs, and bunches of grad students running around. Any one of them was more qualified to do the calculus than I was, and they checked each other’s work to make sure we weren’t going to flush 22 million dollars down the toilet for a stupid math mistake. They weren’t going to trust some programmer with their heavy-duty math, and I wasn’t going to trust them to write a real time device driver to control the custom hardware.

    When I was working on LEO satellite communication, there was a PhD physiscist to tell me how to calculate the orbit. There was an electrical engineer to tell me what was happening to the radio signal on its way from the satellite to me. Again, I didn’t let either of them write real time control software.

    Now I’m working on an imaging application, and there are more physiscists than I know what to do with who are experts on how the photons are detected. But I am not letting them design a high availability service that services large numbers of users by distributing the workload over multiple computers.

    Math can be a part of programming, but, in fact, most of my time is spent on integer math with add/sub/mul/div. I do a little algebra now and then, and maybe a bit of trig once in a while. But mostly, I have not worked on applications where math is a significant part of what I do.

    (Finite State Automata clearly are a part of programming, because programming is all about controlling the actions of one or more FSAs. But I don’t consider those “math”. That is a detail of how a computer works.)

    So I don’t see that I learned anything valuable for my job from 3 semesters of calculus, except that “calculus exists”. If there is serious math to be done, get a math expert to do the math and get a computer expert to make the computer work.