Is Coding Math? Yes & No.

Recently a friend asked me if programming should be counted as mathematics in school. That is a really good question, and I’m going to tell you why I think it should (and when I think it shouldn’t).

A long time ago, in a high-school far far away, I learned how to program. My teachers would tell horror stories of the old days when they had to program room sized computers using stacks of punch cards, and now it is my turn to regale you with tales of coding uphill both ways in a blinding snowstorm. The computer lab in my high-school had 386s, and the language we used was Turbo Pascal. My buddies showed me a little C++ on the side, because, by the second year of programming, we had learned the basics and more — class had become open lab time. (Programming is a lot like chess, in that once you learn the moves, practice is what makes you better.)

Senior year, my project was an RPG in the style of Final Fantasy and many others. Our family didn’t own a computer (few did then), so at the end of each class I would print off stacks of pages of my code on the dot matrix printer. At home and in my other classes I would hand-write out new code or streamline the existing code so that in class all I would have to do is type, debug, and play test. I never quite finished the game, but I was able to create a program that would turn a simple ASCII map into a world you could walk around in by the end of the year.

I was so enamored with programming that after high-school, I briefly pursued computer science as a major. That was a long, long time ago. Why am I telling you all this? Well, eventually, I went on to study mathematics. Once I was in the upper level stuff, I was stunned at how much my programming knowledge helped out when it was time to do a proof. Proof by Contradiction is an awful lot like tracking down bugs in code (something which I was quite familiar with). Induction and Loops are intertwined in my mind. One of the trickiest things for new math students to learn is conditional statements — If, Thens.

So, even though, by the time I was a student of mathematics, my syntax was hopelessly out of date (and it is even worse now) by learning the logic of problem solving, it made me better at mathematics.

It has been more than 20 years since I wrote my first program in Turbo Pascal, I have a PhD in mathematics, and I’ve been teaching math in various colleges for 13 years. This Summer, I have decided to learn a modern programming language — Python — by working through the Project Euler problems.

Why now, after all these years? Because I realized my kids need the benefit of programming, and I plan to teach them. I believe there is no better modern and practical introduction to logic and problem solving. If this is so, then why doesn’t it count as math, since the purpose of math in the curriculum is mainly to teach logic and problem solving? Some of it is entrenchment. But, some of it is how programming tends to be taught in the lower grades.

I’ve recently come across a fun series from Usborne: Coding for Begineers. I say fun, because it is a very simple tutorial. You read the instructions, type the code they give you, and if you don’t make any syntax errors, you get a little game. Don’t get me wrong, I think this is a fantastic way to introduce some of the things that coding can do, but there is absolutely no logic and problem solving. (There is still come other benefit like attention to detail and looking for syntax issues.) For parents and teachers that don’t understand programming, methods like this are the default method of teaching about programming. Methods like this are no more math than asking students to copy a list of worked out problems.

No bug-free code

How does programming become “math”, then? Not by having them use programing as a calculator. By giving students interesting problems to solve (or even better yet letting them come up with their own problems to solve). Admittedly, this is difficult if you are unsure of what coding can accomplish. Project Euler is great for people with an already strong math background (like an advanced high-school student), but some of the problems can be daunting.  Don’t be afraid to skip around some or even google for help (although beware that many people have put full solutions on-line).

For the younger students, I recommend a choose your own adventure style text adventure. Have them sit down and write or draw out the choices and branches (work together if you can). Then, let them program it a bit at a time. Programs like this make great use of conditional statements and loops can be incorporated as well. When they are done, parents and siblings make great play testers.

Stay tuned for more problems to solve using programming. If you have an idea, share it in the comments.

(By the way, I’m not getting paid by anyone to tell you any of this. Links are only provided to save you time googling.)