Oct 9, 2009

Programming Doesn't Always Require Math

This is a response to a recent blog post which poses the question "Do we need to know basic math as programmers?" The author seems to think little of those who have weak math skills. Based on the comments, it would seem many others agree. I appear to be one of the few dissenters, so I will voice my opinion here where I can expand on my reasoning more fully.

The author uses a "basic math" example of flipping the sign of a number. So -5 would become 5, and 5 would become -5. The author's solutions are good, suggesting either to multiply by -1 or to create a function which returns the negative of the parameter (my preference, as it avoids the use of a "magic number"). Some other solutions are presented, some of which were likely jokingly submitted by the respective author, and others perhaps not.

I'll be honest. Math is not my strong suit. When the question was first posed by the author, I had to think about the solution. This lead me to ask myself why I had trouble with this question when so many other people seem to believe the answer should be instantly obvious to anyone with two halves of a brain to rub together.

So I started to wonder - does this scenario even qualify as basic math? It would seem to be more of a factoid principle that is used in practice very rarely. How often would this scenario occur in day to day programming? When was the last time anyone had to perform this task in a real world environment? How often was this task put into practice by most people after it was initially learned? I would think fairly rarely. I can't remember ever doing it. As with all things, a lack of use will breed forgetfulness.

But I digress. Let's tackle the question head on: do all programmers need to know basic math? As per just about every other blanket statement ever uttered, the answer is not an unequivocle yes. My answer actually leans towards the middle, if not no.

I work as a web programmer. I write back end (and some front end) code for a fairly heavily trafficked website. Most of what I do revolves around data: displaying, querying, storing, modifying, etc. How much "basic math" do I need for my job? Unless we include the odd time I calculate widths for CSS properties or manipulate substrings using raw addition and subtraction, the answer is pretty much nil.

There are many websites like mine who's major functions consist of managing users and storing and displaying data. I would assume most of them get along fine with few applications of mathematics as well. I am also fairly confident that many other application categories - to do lists, day planners, system tools, reporting applications, basic control software - do not require much in the way of mathematics either.

Obviously there are a huge number of important and direct applications for mathematics within computer science. After all, if there weren't, math courses wouldn't be featured so prominently in related educational programs. Scientific computing, technical applications, modeling, advanced control software, and more, are all very math intensive. Those of us not blessed with an abundance of mathematical ability would be advised to steer clear of such problem domains. However even within those domains the entire programming team does not have to understand all, or perhaps any, of the mathematics involved. Often there is plenty of room for specialists in other areas - database, clients/server, GUI, etc - within those applications.

Years ago pundits were extolling the virtues of the widget. They theorized that one day business analysts would be able to manipulate widgets to create programs of their own, and that programmers could become a dying breed. While those days are certainly not yet here (and in my opinion will not likely arrive in my lifetime), there is something to be said about the ever-growing level of abstraction we are presented.

It wasn't all that long ago that most programmers used assembly code. I wouldn't be surprised if many younger programmers never do so. I think we can all agree that the vast majority of programmers would never consider writing a major application using nothing but assembly language. We have been spoiled by increasing levels of abstraction.

But this abstraction can be applied to mathematics as well. Just as the "+" operator is an abstraction for the assembly code lurking behind executing that operation, higher level functions can be abstracted as well. In Java, I can use the Math library to perform trigonometry. Even if I were to write an application that involved heavy mathematics, given the right tool set, I may never need to know much about the math involved.

Don't get me wrong. Math is valuable. I envy those of you who excel at it. People like me will rely on people like you to perform - or abstract away - our heavy numerical lifting. But as time goes on and libraries and programming languages abstract away more and more of the lower level programming tasks, as a group, our need to know basic math may diminish.