Do You Have to Know Math If You Are a Programmer?

2024-06-02

Y: Why do you think you don’t?

N: Because they have nothing to do with each other. It’s something people said when I was studying, but then you start coding and it’s just, here call these functions, whatever… What does algebra ever have to do with that?

Y: Ok, let me make a guess here - you had an angry math teacher in school who wasn’t good at explaining anything and expected way too much and you hated math ever since?

N: It wasn’t really like that. And I don’t hate math, but I just don’t see the connection with programming.

Y: So, what do you think math is exactly?

N: Well, that’s a hard question. There’s geometry, algebra, probability, and who knows what else. You can’t make a single definition for all of them.

Y: You can. There is a simple definition that captures all of that. Do you wanna hear it?

N: Sure, go on.

Y: (officially) Math is about designing and researching models.

N: Ok.

Y: Those models must have clear, internally consistent rules. And if you were a historical mathematician, you’d start by modeling aspects of reality. You develop geometry to estimate how much land a rich person in ancient Greece had; or you invent numbers because one is one, two is two, and if you have one apple and another apple, you have two apples - that is so obvious and intuitive that pretty much everyone can accept it and take for granted.

N: Especially imaginary numbers - so intuitive! And irrational numbers also.

Y: And reality is fun and all, but it gets boring after a few thousand years, and you realize your models can’t cover all of it. So you start inventing more involved models, or you go crazy and create models for your models, like some famous mathematicians did.

N: But, by your definition, a lot of things are math. My TODO list is now math because it models what I want to get done in a day. Hell, my shopping list is math.

Y: Yes. Yes, they are.

N: And physics is math, but I can kinda see how it would be.

Y: Well, yes but with some caveats.

N: Oh, really? Shopping lists are fine, but saying physics is math, that’s going too far?

Y: Math wants to keep things clean. It hates mess. Actually, it hates vagueness. Those models must have a very clear set of rules. Physics has a modeling aspect with its formulas and whatnot. But physics, chemistry, and other such sciences involve having to deal with reality in dirty ways that aren’t fully defined.

N: It feels to me like you haven’t fully thought your definition through. But, sure, reality is too messy to truly model. The models themselves are math, as you state, but anything that’s messy or handwavy may not be.

Y: Exactly. Anyway, math is about coming up with a set of rules to describe something and then those rules are followed precisely and to the letter, with zero subjectivity! And then you allow those rules to play out and yield a result that’s determined by their definition. Another part of this is that you’re creating a framework or a language for dealing with the model and…

N: (smirking) That’s programming. You just described programming.

Y: Well, hey! How about that?

N: Ok. I don’t know… This definition feels way too broad, suddenly anything could be math.

Y: Why do you think some people say that God is a mathematician? Or that math is the mother of all sciences?

N: I mean, all reasoning and logic is now math. Whenever we think, you’re saying we’re kinda doing math.

Y: Math is one of our main tools for dealing with reality. But, I’ll admit the definition is just something I pulled out of my head in the heat of the moment. There’s actually no accepted definition for what math is.

N: Ok, sure, when I program I often have to convert loose demands into formal requirements and then put them into code. And that code will have functions and classes, and I also have to name those. So, in your view, the art of doing all that is a form of mathematics?

Y: Yes! Thank you for adding to my point. All those fields you mentioned - algebra, geometry, probability, they all model something, or at least can be used to model things, and coming up with such abstract representations is a cornerstone of what it means to be a mathematician.

N: Huh. I still think your definition of math is too broad, but you did convince me that I wasn’t thinking about math the right way. I don’t fully agree with you, but let’s compromise and say that doing math and programming share some of the same neural pathways, so to speak.

Y: Sure, I’m happy with that.

N: But I have two points I want to bring up now. First, what are we really discussing here? My question may have been misguided, but it was originally about whether someone has to know specifically linear algebra, trigonometry, and the like for programming. I don’t think so unless they’re working on advanced stuff, like computer graphics or cryptography. It may occasionally help, but not too often.

Y: Oh, I agree. I’d even say that if you’re, for example, using linear algebra while making a game, you’re actually briefly pausing your programming work to do just math. Then you come back to the actual programming part to code in the matrix formula you derived on the side. In that scenario, math and programming are independent actions. But, when you are programming, you are applying a skill set that is closer to a mathematician’s than you give yourself credit for.

N: It’s like that meme: “You know, I’m a bit of a mathematician myself”.

Y: People tend to have a very narrow view of what math is. I don’t like when people think that, because they’re not solving equations or multiplying numbers, math is not programming. Number calculations are to math what calligraphy is to being a successful novel author. It would be like someone thinking that knowing a particular JavaScript framework is the entirety of programming.

N: My other point is that the programmer job is about a lot more than coding. We have to put up with meetings, documentation, and badly designed and buggy APIs. How do those relate to being a mathematician?

Y: You’ve clearly never worked in an academic environment. Well, neither have I, but they too have their problems: terminologies and communication aren’t easy, they have to fight for funding, the whole publish or perish thing… Even if your job is math, you have to deal with a lot of stuff that isn’t math.

N: Yeah, I guess the grass is never truly green.

Further reading

https://softwareengineering.stackexchange.com/questions/136987/what-does-mathematics-have-to-do-with-programming/137075#137075

https://j2kun.svbtle.com/programming-is-not-math-huh

https://qr.ae/psJ7JB (https://gist.github.com/arvearve/4158578)

https://www.math.toronto.edu/mccann/199/thurston.pdf