HACKER Q&A
📣 larridde

How important is math for software engineering?


I'm well aware that you can learn programming, data science, etc... without being good at math, but one thing I always keep hearing is that; the better you are with math concepts, the better your problem-solving skills become. Seeing how many things in programming derives from concepts in math (functions, vectors, matrices, etc...), do you believe having a strong foundation in math would help someone in this type of field?

I really want to hear your opinions on this, how much beneficial is math for software engineers? Does having a strong foundation lead to better problem solving? If two programmers were assigned a task and both of them have spent an equal amount of time (let's say 10k hours) practicing programmers, but one has better math knowledge than the other, would that person be able to produce a better/faster solution than the other guy?


  👤 hedora Accepted Answer ✓
Discrete math is extremely important if you want to write correct or efficient systems software. It doesn’t give much of a “time to first solution” win, but most people I know with strong discrete math backgrounds produce systems code that is simultaneously about 10x more concise, performant and correct than those that do no. (The Haskell and TLA+ crowds get this, but I’m talking about C++ and Verilog code here.)

If you want to do machine learning or use supercomputers, then normal undergrad math like Linear Algebra, Diff Eq, etc. matter a lot.

If you’re happy writing CRUD frontend logic, then you probably don’t need much math. If you want to build the stuff that relies on, then math will help a lot.

This becomes more true past the 5-10K hour marks, partially because you need the math, and partially because the math background will make it easier to sustainably improve your skills.


👤 kovac
I'm a software engineer who majored in Mathematics in University. You don't need that level of mathematics to become a software engineer.

You do need basic mathematics (like secondary school or O/L) to know basic arithmetic operations, remainders and modulo operations, binary numbers and some basic low order logic like for OR, And, stuff. Having a solid high school level mathematics would be an advantage.

In terms of state of mind when I did maths vs programming, programming is more akin to solving IQ puzzles or school math problems that are computational in nature(perhaps a little easier?) more than doing university maths.

Where I did feel an advantage having done advanced maths is in fields like encryption (you learn this stuff in full general forms in abstract algebra, coding theory in high level math), abstractions (software engineering abstractions like programming interfaces, classes are a piece of cake compared mathematical abstractions), certain algorithms.

Short answer is actual mathematics is less important than the ability to grasp abstractions and think in a disciplined, qualified way (like in maths how you go from axiom to axiom, or theorem to theorem qualifying each step). If you don't have a previous maths background you can learn it on the job as long as you have the above raw skills. If you don't enjoy that kind of thinking, I'm not sure if you'll enjoy certain subfields of software engineering though you could still go into UI programming. Either way, if I didn't have a chance to learn maths even at a primary school level, I wouldn't have let it prevent me from trying to be a software engineer.


👤 ssivark
Depends on what level of math you’re talking about. Math is nothing but a bunch of (fairly) basic algorithms (often expressed declaratively, rather than imperatively) for solving problems in the real world. Sometimes you also have fancy data structures like vectors and objects like polygons and what not. If one is solving problems in the physical world, that is super useful. It like a compiler which ensures that you will not make (a bunch of) simple conceptual mistakes, and will make several ideas obvious (I often see programmers spending time on iteratively refining heuristics when either 1. Math tells you a good answer 2. Math tells you the problem is ill-defined and impossible to answer). I would consider it even more primary than a course in data structures and algorithms. In other domains like front end design, an aesthetic sense and understanding of colors and typography might be more important. So math is always useful (adds some value), it’s just a question of where it comes on the list of priorities. Math can be picked up with domain experience, just like software dev skills, or whatever else. And specialization is a thing — one can choose to develop skills selectively. Someone building CRUD apps might not give a damn about mastering coordinate geometry, and someone working in robotics might instead not give a damn about mastering category theory (generically). YMMV, and it’s meaningless to try and “settle” this question. The answers depends very much on the specific set of problems/experiences you consider. So the answers are only going to tell you about the distribution of people on HN (who might bother to answer a question like this); refer Wittgenstein’s ruler.

If you feel FOMO for a topic, consider spending some time with it (whatever the subject). Otherwise, carry on blissfully. I would consider many other topics as important, but we all have limited time. C’est la vie.


👤 Mikeb85
I think you can learn whatever maths you need to be a programmer on the fly, unless you're in a specifically math-y domain.

👤 nwallin
Depends on the application. A lot of stuff, especially in CRUD world, doesn't need any. A lot of stuff really leans hard on it.

The least terrible one sentence rule of thumb is that the more SIMD could help make your code faster, the better at math you should be. It's a really weird rule, but for some reason it works.

Specifically regarding the generalized good at math, therefore good at problem solving, don't think too much into it. There's a lot of correlation/causation problems in there. A BS in mathematics will not make you a better programmer than a BS in computer science will. If you're going to do four years in college anyway, sure, pick up a few extra math classes. (especially linear algebra) If you're going the self taught route, (I couldn't make the transition without the piece of paper, ymmv) watch the mit ocw (or from whatever other college) series for the first semester of linear algebra, discrete mathematics, and calculus. You don't need the second semester.

I do GIS, which is a lot of spatial modeling. Linear algebra is an everyday thing for a lot of us. Many others don't need any, because they deal with networking, databases, static UI, etc. Don't think you'll be locked out of a certain field just because you don't know the required math, but also know that knowing the right math will grease the wheels.


👤 aichbauer
To keep up with your first sentence: Yes you do not need to have good math knowledge to start programming, and I would say if you do not have good understanding of math you really should start to get into software engineering.

My two cents on software engineering and math.

- When you start programming, and you start to develop complex algorithms, you will increase your mathematical knowledge just by trying to solve your problem. It is not different from school. When you are a kid and study math, first of you do not have mathematical knowledge at all. I do not think that there are talents, that have a better understanding in some areas just because they were born. Most of the people that are good at math in school, are interested in math, and that's why they try to get better at math. So they practice math. So if you are interested into programming and you come up on a math problem, and your urge to solve the problem, and your interest into software engineering and creating stuff is bigger than your fear of math, the result is you getting better at math. It is simple as that. So if you are interested in stuff you will learn and practice and you will get better at it.

- So your urge to solve the problem in the best mathematical way is not higher than your interest in software engineering: You still should get into SE because you can always create stuff, even if it is poorly implemented. This is not me saying one should start learning bad programming practices, but saying people should code. You do not have the best programming skills, and mat knowledge to create something that solves a problem. And if this project of yours solves many problems, there will be people you can hire, that are better than you in any discipline, and they will do the rest...

Cheers and have a nice day :)


👤 forkexec
Don't feel inadequate for lacking academic baloney. I did a BS CS & Eng degree (heavy on the BS) that required diff eqs, linear algebra/vector analysis, abstract math, concrete math, physics (the whole, real series), quantum mechanics, chemistry (the whole, real series), statistics for CS and then all of the lower-div and upper-div CS and EE requirements. At one point, I was two courses away from a math major; no joke. :''') Hehe.

Design creativity is something you can improve through play, experimentation and practice.

If you really want to learn math beyond algebra or calculus for fun or personal enrichment, there are MOOCs: several on KhanAcademy, some on Coursera and hundreds at the link below, some look quality (Stanford, MIT, SJSU, UT Austin).

https://www.classcentral.com/subject/maths


👤 BjoernKW
I'd say it's important for the reason you mentioned: Many programming constructs and metaphors are either derived from mathematical concepts or a direct implementation of these concepts.

Good programmers without a formal maths education by and large probably just have a good intuitive grasp of these ideas.

That said, a lot of the maths commonly taught at university isn't all that relevant for programming from a pragmatic point of view (and it isn't meant to be, given that computer science is about much more than just programming).

Interestingly, the rather theoretical formal methods courses from my linguistics studies covered quite a few concepts that are relevant or useful for programming in general (first- and second-order logic, set theory, lambda calculus).


👤 creatornator
It depends heavily on the programming domain. There was a reddit thread recently [0] describing how someone spent a bunch of time reinventing matrix multiplication. Certainly with some more background in math (and maybe MATLAB in particular) they could have saved a bunch of time.

Surely computer science research problems require some rigorous proofs and applications of theory. But your general web app or command line utility for wrangling data? Might not make much of a difference.

[0] https://www.reddit.com/r/matlab/comments/fbhq9c/a_friend_of_...


👤 winrid
In my experience the talents do not require one another, in the way I think you are thinking of it :)

At its core math is logic. So yes better ability to solve logic puzzles will win here. However you can have those skills and not teach yourself physics/calculus/advanced algebra etc.

Also regarding coding/problem solving talent - you can make a company many millions of dollars a year without ever taking calculus (I did it). Although, I like math, I just never made a huge investment in it. I am the kind of person to sit around and do math for fun, but I don't consider myself knowledgeable in that field.


👤 injb
I don't completely agree with most developers on this question. I can't respond properly now but i recently wrote a lengthly comment[1] on a blog post that was posted here on HN on this topic. I'd suggest reading that and the author's response, and my "further reading" link to Steve Yegge's timeless blog.

[1] https://scientificprogrammer.net/2020/02/21/why-you-dont-nee...


👤 0x1221
> I'm well aware that you can learn programming, data science, etc... without being good at math

I don't think that this is accurate for data science. Data science is essentially software engineering + math.


👤 AnimalMuppet
It's important to be able to reason in a math-like way. The actual math? As reatornator said, it depends on the domain. More: Which math is important depends on the domain.

👤 gentleman11
Depends what you’re making. At my last job and for my current project (both had a graphics component), vector math means you don’t need to go looking for somebody to help when things get tough. It’s nice to be the guy/gal people turn to for help. You don’t have to be though unless it’s a very tiny startup where there isn’t anybody to turn to

👤 32gbsd
Personally I find that it mostly comes down to the ability to focus on an issue and see logical relationships between metaphysical structures. I am average at math in general but very good at algebra and Set Theory.

👤 echan00
Generally not very important if you're talking college level math. I would say it's very unlikely you'll need any math skills beyond the intro calculus and linear algebra in college.

👤 mimixco
I don't think it matters one bit. I never liked math until I already had a successful programming career. To me, programming is much more about language skills than math.

👤 shoo
> If two programmers were assigned a task [...] would [person with better math knowledge] be able to produce a better/faster solution?

It really depends on the task. If you work as a software engineer in a somewhat enterprisey setting, arguably many tasks don't even particularly require engineering or programming knowledge, let alone knowing any mathematics beyond high school level.

From working on a couple of decision-support-systems for larger enterprise clients, maybe the core 5-10% of some decision support systems needs some nontrivial understanding of operations research (e.g. linear programming, mixed integer programming techniques) / applied math (how to approximate functions & compute them efficiently) / basic comp sci algorithms concepts (e.g. graph theory to model networks for flows of traffic, goods, project dependencies, etc). The remaining 95-90% of the programming work is stuff like data validation, arranging things (data, code, libraries, build scripts) so they can be kept organised, writing tests, bolting on reporting systems, adding extra fields to things, figuring out how to cope with missing input data, etc. These kind of math-oriented decision support systems probably cannot be built with at least one person involved who is across some of the theory/practice of how the core of the system can be designed and built. So the difference between not having someone with a decent background in applied math/OR/graph theory on a project like this might be: the project just fails --- maybe something gets delivered and perhaps the client accepts it, but it probably doesn't really work.

But, that said: most of the programming work in the business world is essentially unrelated to maths/algorithms/OR stuff. Most line of business software projects have no clever core at all, e.g. web service exposing CRUD API for some kind of enterprise data. In these settings it is far more useful to be good at something like "project management" or "requirements analysis" or "designing the data model" than math, since the projects need essentially no math beyond perhaps the ability to do capacity planning or estimate if the design is going to under-perform massively.

If you specialise in some tricky kind of maths then depending on what you specialise in exactly there is some career risk that you will be very good at solving problems that hardly anyone has, so it may be hard to find work in that area, and if there are more specialists than work, the work may not pay that well when you find it. From a career perspective, if you are flexible about what you do for a living and what you learn, it's perhaps better to ask "what skills are likely to have demand outstripping supply in the future? which ones would it be feasible for me to learn? do some of them sound more interesting to me than others?".


👤 lincpa
Mathematical thinking is helpful for software engineering, but mathematics itself does not directly help software engineering most of the time.

I think that large industrial production management technology can help software engineering more effectively and directly.

This is [The Pure Function Pipeline Data Flow v3.0 with Warehouse / Workshop Model ](https://github.com/linpengcheng/PurefunctionPipelineDataflow)


👤 tropo
Math is beneficial for software engineers because it limits competition. People change major because of the math.