skull

Robert Tamayo

R
B
blog
skull

How Important is Math to a Programmer?

Before I knew what it was called, I was using something called procedural graphics. I figured that as a solo game developer, I couldn't spend too much time drawing everything I wanted to draw, so why not code it instead? In the process, I created some pretty incredible effects for a game called RoboBot with nothing but lines of code. 

My favorite effect was a Waterspout attack. I was able to create an amazing water tornado effect with nothing but triangles. TRIANGLES.

Trigonometry and spatial reasoning ended up compensating for my lack of artistic fluency.

I don't generally use math in programming as much as I want to. I find this ironic, because one of the reasons I love programming is because I can use it to AVOID math.

That's right, programming helps us avoid math. Don't believe me? Multiply 6174 by 32950 on a calculator. That's why I love programming.

Some people, whose gifts we once considered savant, are now only good for performances. Von Neumann is reported to have summed a geometric series in his head, instantly. When I was starting out programming, I would use Java to solve geometric series for me, thus avoiding the tedious process of adding the numbers up together. (The "for loop" is one of the first things you learn in any programming course/book.)

Of course, there is something to be said of mathematical ability. After all, asking you to multiply 6174 by another large number on a calculator is easy. Writing a program that can do that, however, is another task altogether.

Computers have made addition and multiplication easy for us, and even common mathematical requests are made easy by any modern programming language. What's the sine of PI times 3.432, JavaScript?

So if everyone else has figured it out for you, why should you care about math? Or even more importantly, why should you care about how good you are at math when deciding to take up programming?

Before I answer directly, here's my answer indirectly:

I was 25 when I first took up programming. I was a mere lad, and had literally NEVER looked at a line of computer code without contempt. Those nerds.

However, I always instinctively knew I would be good at programming. How can I have known that even thought I non-millenially literally knew nothing about programming or even computers? (Okay, I could write an essay on Word with space characters at 1.2 font size to add an extra half page to my 5 page minimum essay. But that was survival.)

I knew with certainty that I would not just be good, but excel, at programming. I had only avoided programming because I thought I would get too caught up in it. I was so confident in my ability that didn't exist, that I avoided it altogether for fear of actually being good at it. The word you're looking for is "stupid".

But how did I know? I knew because of several things. I KNEW I would be good at programming because, before ever even looking at code, I was good at or had an interest in the following things:

1. Music
2. Psychology
3. Philosophy
4. Linguistics (mostly via study of foreign languages)
5. Video games
6. English (grammar, spelling, and punctuation)
7. "Thought, and thinking" as I once put it
8. Drawing
9. Humor
10. And finally, Mathematics

I had the instinct to understand that programming was going to be a combination of all of those things. Five years of experience later, and I can tell you it certainly is.

So how is math involved, then? Math is important because computers compute, and computation is the term used to describe doing a lot math.

Computation, by definition, involves math. I don't really agree that we have to think about programming at the deep, mathematical level that it really is, because a lot of modern programming languages almost completely hide that fact altogether. Most people will argue that math is needed at the basic level for programmers, but not much more than that, because at most you will need to add, subtract, or multiply the correct values together. 

But I argue something different. I argue that math is very important, but not necessarily any math you may have learned in school. What's important is not so much math itself, but mathematical reasoning.

Mathematical reasoning involves thinking about logical and spatial relationships at an abstract level. If someone gave you a problem, how do you solve it? Can you think about the problem? Can you break it down to its base parts? Can you identify the principles at work? Can you think of whatever else might be affecting the problem that's not included in the question? Can you think of another, similar problem that is related but different in a particular way? What if you introduced another factor to the problem? Does it change everything, or does your solution still hold because it accounted for an anticipated interruption?

That's why math is important at the problem-solving level. Being good at math will help you identify patterns and use them to find the solution that always works, because that's what programming really is – finding the solution that always works.

But at the spatial end of things, understanding a problem spatially is invaluable. Trigonometry helped me do incredible things, and that was just one application of spatial reasoning. Being good at math comes with another perk – the power of "seeing" data. Being able to see data is crucial when you are writing an API that can fetch blog posts written by Robert from the last 3 months with a category of "funny" and a tag of "cats". (That would return 0 results btw, because I hate cats. For fellow programmers, it returns 404 or even 500 depending on my mood.)

If you want to be a front end web developer, you can get by without much math knowledge. But if you want to get to that next level and really excel at front end development, mathematical reasoning will help you incredibly. If you can visualize abstract concepts, or at least navigate them with a compass, you will be able to identify sources of bugs as if you were you inside the computer itself.

I think that's the biggest takeaway. Understanding math helps you get "inside" the problem you're working on. If you can't solve a problem, you can't program. If you can't solve a word problem, you can't program. That's because programming is not solving a word problem. Programming is WRITING the word problems. The computer is just the sucker who has to solve them.

Comments:
Leave a Comment
Submit