Is it necessary to know math to be a good programmer?

Most universities require math as a prerequisite in order to take a class in computer science. Many people never take a class on programming, because they dislike math. I have often wondered if math is truly necessary to be a good computer programmer, since many people never try programming because they are told that it is like math. Most working programmers, however, will tell you that they rarely if ever use math while on the job.

Knowing math certainly helps you understand programming better, but it isn’t necessary for the majority of programmers on a daily basis. You need it if you are doing analysis of algorithms and trying to figure out whether one search algorithm is better than another. You might need it to decide whether to use a linked list, a b-tree or a binary tree to store your data. However, very few programmers today need to do that sort of low-level programming. 99% of programmers let databases handle data storage and searching.

Since 2009, when I started working at ProcessMaker, a company that employs roughly 100 programmers, there has only been one time when I encountered a math problem on the job. We have a plugin that calculates the key performance indicators, and I wrote a bug report saying that the KPI we created was not useful and I suggested we use a different variables in the formula. I spent half an hour plugging values into a formula with different variables to find the boundaries of the possible results. I would have noticed the problem even without my rudimentary math skills.

Math helps you think logically through a problem, and in programming you have to think logically, but I don’t think that math is the only way to approach a logical problem. Math is not required to be able to think methodically through a problem by asking if this happens, then what follows. At any rate, 90% of the problems I encounter while programming are solved by dogged trial and error. Math might help to later figure out why something works better, but when you are faced with many possible routes to try and accomplish a task, the most important thing is first do the task and then optimize later if proves to be a problem. In other words, overanalyzing a problem with math can actually get in the way of being productive. There is a saying in programming that you should never pre-optimize a problem, but always be prepared to measure afterwards in order to post-optimize.

However, you do need to know math if you are going to understand many concepts in computer science. There is a big difference between a person who formally studies computer science and a person who does high level programming using many preexisting tools, which is the vast majority of programming today. If you are designing a new compiler, database, video compression program, 3D game engine, etc, then you definitely need to know math, but very few programmers do that kind of programming.

For me math is inherently fascinating, but I was never very good at it. I like to think about it, and play with it, but I was never very fast at it and I never got the best grades in math class. I was never one of the people for whom math came naturally, but once I figured out how to do something in math, I took great enjoyment in using it and pondering it. As a history major in college, however, I stopped taking math after the second year of calculus, so it is hard for me to evaluate whether knowing more math would make me a better computer programmer.

I also never learned a lot of the theory in computer science, because I taught myself to program by reading books on my own. Studying on my own, I could take as much time to learn what I found fascinating and skip what didn’t interest me. I recall when learning C that I spent hours writing out and playing with the algorithm to convert binary to decimal and back again. I found binary math and the ways computers add and multiply to be utterly fascinating. At one point, I started programming in C++ a set of classes to be able to do mathematics at any precision, because I didn’t think that 64 bits was enough. That meant that I had to write code that would do addition, subtraction, multiplication and division at a very low level like a computer.

The real question is whether you need to understand the math that underlies the tools which you are using in programming. Probably not, but sometimes its useful, especially when trying to figure out how to optimize something. I use encryption on a daily basis without really understanding how it works. Then, one day I looked up the algorithm for MD5, which is simple enough that you can implement it on your own in half an hour. Then, I read Steven Levy’s book, Crypto, which is a fascinating history of cryptography and the people who promoted its use. Now, I have a much greater appreciation for the cryptography that I use on a daily basis, but it hasn’t made me a better programmer. I would say the same about math in general. Knowing it helps you appreciate the beauty of an algorithm and makes programming more interesting, but it isn’t necessary.

Programming is more fun, when you can entertain yourself by thinking about the underlying math. Just like it is more exciting to learn a new language if you have ever taken a class on linguistics, because it gives you a framework to think about what you are doing on a practical level. Understanding math makes programming inherently more fascinating and enjoyable, but I can also say the same thing about many spheres of knowledge. I read every book I can find about the history of computers, which also makes programming much more enjoyable when I think about the evolution of the technology. Some people start to program because they find games fascinating and want to create their own games. Others start because they want to create cool web pages, and it would be nice to add a bit of JavaScript to their page. Programming is as much an art as a science, and there are many routes to becoming proficient in the art.

In my case, I had a summer job where I had to spend hours doing repetitive tasks over and over in WordPerfect 5 and I thought, “what a waste of time!” I cracked open the big three ring binder that came with WordPerfect 5 and started reading about Macros. The manual was cryptic and filled with examples that assumed that I already knew the basic concepts of programming, but I persisted because I found it cool to be able to plug in something and see what would come out. It was addictive, even if I didn’t understand what I was doing. I decided that I wanted to really learn programming and I wanted to learn the hardest and most cryptic language, so over Christmas break my senior year in college I spent 3 weeks reading a book on C programming. I didn’t have a compiler and I wrote out my programs using pencil and paper. For me, it was just fun to play with the ideas. I had no pressure to get a good grade or produce anything. It was a purely theoretical exercise, like learning Cartesian philosophy. After I learned C, then I learned C++. After that I read a book about data structures where all the programming examples were in Pascal. Later I read books on BASIC, Java and Python. Today, almost all of my programming is in PHP and JavaScript, but I still find programming to be a fun mental challenge.

The important thing is to find programming inherently enjoyable and fascinating so you will continue to learn and become better at it. If math gets in the way of learning to program, then I would say, “don’t worry about it,” because you can enjoy programming without knowing a lick of math. Only a tiny segment of programming requires using math, and programmers have so many interesting and exciting things to work on outside that tiny segment.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s