DEV Community

How important is math in computer programming?

Douglas Makey Mendez Molero on January 08, 2018

I’m writing this article because I recently did this exercise in HackerRank: I don’t have a degree in computer science or similar (but i’m worki...
Collapse
 
leob profile image
leob • Edited

I'd say a formal math education is totally unnecessary for 99% of the programming tasks, however people who are good at programming will in general also be good (or at least okay) in math. To be good at programming requires the ability to think in an abstract, analytical and systematic way, and that goes for math too.

On the other hand, I've read (and believe) that performing programming tasks activates the "language" part of the brain rather than the "math" part of the brain.

So I'd say there are ties or commonalities between the two but I wouldn't overstate the importance of math for being a good developer in general.

The story changes of course once you venture into numerical/scientific programming or data science.

Collapse
 
ionutarhire profile image
Arhire Ionut

Hi! Could you tell me where you read the thing about programming activating the "language" part of the brain please? I'm interested about it.

Collapse
 
leob profile image
leob

Yes absolutely, I don't know where I read it originally but it was easy to google it. Scientists put programmers in an MRI scanner and then analyzed which brain centers were activated when they started to study/read source code. Their conclusion was that primarily the "language" center of the brain was activated.

In case you'd want to read the original research paper: infosun.fim.uni-passau.de/cl/publi... however here is a good layman's summary:

medium.com/javascript-scene/are-pr...

and another one:

huffingtonpost.com/chris-parnin/sc...

and some discussions:

reddit.com/r/askscience/comments/7...

Now, my take on it is that I'm not surprised by this outcome, not just because "programming language" has the word 'language' in it, but also remember the phrase "well written software reads like prose" (or like a novel).

Also remember the importance of stuff like choosing good (meaningful) variable names, and so on. Having an excellent command of native or natural language has got to be a foundational pillar for at least a large part of programming.

On the other hand, I noticed that there are many articles on this topic, but all of them seem to refer to the same scientific paper with the MRI scanner, so the scientific basis seems to be a bit narrow (only one group who researched it), but it seems reliable enough.

However, the scope of the study is fairly narrow - only reading source code. What about writing, what about debugging, testing, what about other activities associated with 'programming'? I dare to make a prediction that additional "centers" will be activated, but these kind of scenarios weren't scientifically studied (with MRI and whatnot).

Also, reading source code may be a little like reading a book (detective novel?) but grokking a complex system also seem akin to taking apart a complex piece of machinery.

So all in all I believe the basic premise of the theory but I'm convinced that it's only part of the story and the full picture is a lot more complex and nuanced.

Thread Thread
 
ionutarhire profile image
Arhire Ionut

Thanks a bunch! I agree with you entirely. I read the articles and the thing is, we're just going to have to wait for more in-depth studies to come out to form meaningful opinions on the subject. Still a very interesting read and I recommend it to any developer on here.

Collapse
 
craser profile image
Chris Raser

I think this is a case of everyone being generally right, but saying the same thing in different ways.

Having been a dev for ~17 years, I agree that most tasks I perform each day can't be expressed in pure mathematics as easily as the kangaroo problem above.

Also having been a dev for ~17 years, I agree with you that for some problems, a mathematical solution is superior to an algorithmic one.

You seem to see clearly the relative importance of mathematics in software development. That is far more important than who's right or wrong in this case. :D

Cheers!

Collapse
 
tanjent profile image
tanjent

I would say that a strong understanding of algebra, functions, and boolean logic/truth table work is pretty much required for any developer.

Beyond that, it really depends on the type of work and the problem domain you work in. Certain technologies, and certain problem domains can require additional mathematical skills for you to understand the problem you're solving, and be able to relate to it in your code.

For instance, someone heavily involved in relational databases needs a strong understanding of set theory (the basis of SQL). If you're working in a bioinformatics realm, you need a strong linear algebra and statistics background. If you're doing real-world modeling (eg, simulating for airflow over a wing), you'll need to understand the physics involved (and hence the math required by that physics).

Collapse
 
thetuftii profile image
Claire Pollard • Edited

It depends on the type of programming job you have I'd say. For mine working on CAD/CAE software it's critical as I have to read/write academic research at times to implement complex/unique algorithms to do a particular job. It's fairly maths intensive at times, with lots of geometry and topology.

Also, Mathematics is more than just numbers and equations, it provides you with a logical way of breaking down a problem and gives you a toolbox of thought processes to use when trying to solve a problem.

So I'd have to sit on the fence for this one. I'd say it's not essential for all dev jobs, but can help for some software development roles.

Collapse
 
6temes profile image
Daniel • Edited

It really depends on what you are programming. If you want to become a video-games developer, you absolutely need to know maths. Specially geometry and vectors.

For Neural Networks, you will need to know calculus in order to understand the papers.

If you are a web developer and work with a high level programming language, literacy skills are the most important because your main job will be, not making the computer do what you want, but understanding other developers' code and write code that other developers can understand.

Being able to code a big amount of business logic without making a spaghetti mess, is a really important skill to have, and it does not require any knowledge of mathematics.

Collapse
 
mortoray profile image
edA‑qa mort‑ora‑y

Algorithms are math. Logic is math (and philosophy). Finance is math. Statistics is math. Metrics (QA, Marketing, Business) are math.

Math is a large field of study. There are obviously portions of coding that have nothing to do with math, but the vast majority of it involves math in some way.

I find it hard to believe that somebody could be a good coder without being good at least some aspects of math.

Be leary of coders who say they don't know, or don't like math.

Collapse
 
xicarus profile image
Sergiu-Lucian Petrica • Edited

"Be leary of coders who say they don't know, or don't like math."

This is a silly statement, how does a preference to a potentially unrelated field of study relate to the skill of the developer?
Web developers very rarely need any advanced math concepts for example. If you're not gonna hire a web developer because he doesn't like maths you're gonna have a hard time hiring. In fact from my personal experience most developers don't like maths. In Romania they go to Informatics universities as opposed to Mathematics-Informatics ones in order to evade a large part of maths.

Collapse
 
mortoray profile image
edA‑qa mort‑ora‑y • Edited

Do you disagree with my assessment of the breadth of the math discipline? Or are you really saying that a coder could get away without know any math what-so-ever?

Thread Thread
 
xicarus profile image
Sergiu-Lucian Petrica

I said advanced mathematics, you obviously can't get away as a programmer without knowing basic maths.
However generalizing that a programmer who hates maths is a programmer you should avoid is beyond silly. It depends on the subfield. If you're gonna hire a game engine developer who doesn't know trigonometry or linear algebra of course you're gonna have a bad time, but if you're hiring a mobile developer you don't care how good he is at calculus.

Collapse
 
patricktingen profile image
Patrick Tingen • Edited

Math is important, but not because of the mathematics.

Instead, it is important because it teaches you to think structured, so math is not the aim, it's the means. It teaches you analytical skills that you need to solve programming problems.

Because jumping kangaroos are rarely interesting ...

Wumo of today
source

Collapse
 
cyberspots56 profile image
John Rainey

First, I would say that Discrete Mathematics is very important. You learn Boolean logic and set theory. Nice things to know when writing software. From my own personal experience mathematics has been quite valuable. For example, you are working on an application that requires the best possible performance. You have two algorithms that you are considering, but which one will be faster? I have used mathematics extensively to make this decision. It's so much easier to do a little calculus than a series of tests with actual data. I spent my career working on apps where execution time was vital. Using a little math always seemed easier to me.

Collapse
 
dougmckechie profile image
Douglas McKechie

How important is math in computer programming? My first reaction would be "not much" as I've never needed to do much math as a web developer. But I suppose the importance of math depends on what sort of development is being done.

Interestingly I just mentioned to my sister the other day how often people used to assume I was good at maths because I worked in IT (which is not the case). Does anyone else have that happen to them?

Collapse
 
Sloan, the sloth mascot
Comment deleted
Collapse
 
ivxxcatto profile image
Alejandro

I'd like to add that most people think that math is all about equations and formulas, but it really is much deeper and beautiful. Math is the study of how things work and ultimately how the human mind things and deals with complexity.

You are right that math is very useful (it also depends on what kind of coding you do) but it is also very interesting and beautiful by itself when you learn it the right way. I think many people dislike, fear or misunderstand math because it is not taught correctly in schools.

Congrats for being eager to learn and improve your skills, you are on the right track here.

Finally, I would like to recommend you a coupke of things:

The paper "A mathematician's lament" by Paul Lockhart talks about what's wrong with how math is usually taught. A very nice and entertaining read.

The books "The art of computer programming" and "Concrete Mathematics" by Donald Knuth and others ate simply awesome. Try Concrete Math first as it has the math needed to read the art of computer programming and it really makes you think a lot, it is hard but rewarding and beautifully written.

Collapse
 
databasesponge profile image
MetaDave 🇪🇺

In the last 25 years, the only serious mathematics I've used was part of a forecasting system, in which I had to take forecasts of A, B, and (A-B), where A & B were a couple of orders of magnitude greater than (A-B), and adjust the forecast values of A and B (lets say Af and Bf) in order that the (Af - Bf) was equal to the the forecast of (A-B).

Now I didn't do the forecasting, I just had to do the adjustment, and it turned out that to so I had to solve a quadratic equation using the classic method.

In Informatica Powercenter.

Collapse
 
vithabada profile image
Vít Habada • Edited

Law of diminishing returns.

You can be a great programmer without the formal knowledge, sure.

Learning all the math and computer science stuff is hard. And most of the time you don't need it (compared to other coding-related skills others mention), but when you do - boy oh boy it matters alot. Your simple excercise is a great example.

So on the importance - the answer is as usual 'it depends'.

I think most important, generally, is to understand how things that you use work. That includes some math, but more importantly it includes knowing how memory is managed, how the VM that's running your javascript code works and what sort of optimizations it does and so on.. Once all that knowledge fits together it feels really good to know exactly what you are doing.

Collapse
 
maxvonhippel profile image
Max von Hippel

It completely depends what you are doing. I used Quaternion.slerp in Unity3D on an almost weekly basis in my part-time job for 2 years during high school, and only just learned what Quaternions were and how to use them mathematically this year (and I'm a junior pure mathematics major in university now).

Likewise, you could make it pretty far into using something like Torch for AI/ML without learning abstract or linear algebra, I think.

Understanding boolean algebra - which is a lot simpler than it sounds - is very useful. It lets you write shorter and more concise logical statements and better understand overall how computers work. It is absolutely essential to even starting to understand computer hardware at the chip level - for example, CPU design. But a lot of people work for years and years as software developers/engineers and never encounter any of that stuff.

In university, I often learn more in my free time on Stack Exchange and from extra textbooks than in class. Classes provide tests, structured learning, and homework sets, but at the end of the day we have to learn a lot of the material on your own. So not going to college for math or CS isn't necessarily a big deal - it just means you have to learn a bit more on your own than most people.

One area where I feel math really helps is any sort of scientific modeling. I can't imagine doing modeling without having 2 semesters of fairly advanced linear algebra under my belt. That said, a lot of statisticians do similar work from a statistical perspective, and I'm not sure that they all know about metric spaces, vector spaces, fields, groups, etc. etc.

Collapse
 
yaser profile image
Yaser Al-Najjar • Edited

Let's just cut the crab...

I have taken lots of practical math cuz I enrolled in computer engineering (Calculus 1 & 2, Linear Algebra, Statistics & Probability, Differentail equations, physics 1 & 2)

And hell no, I have never used those for the 7 years passed in building enterprise software.

Collapse
 
quii profile image
Chris James

I'm saddened by people being dismissive of mathematics here but I think it's because a lot of people dont see maths as being much more than arithmetic and statistics.

I strongly urge you to look at Category Theory, which is a branch of maths.

It is a broad area which is concerned about formalising abstractions, such as sets.

Formalising abstractions Does that sound familiar? If you have any interest in functional programming you owe it to yourself to investigate it.

Category theory has practical applications in programming language theory, for example the usage of monads in functional programming.

en.wikipedia.org/wiki/Category_theory

Collapse
 
lobsterpants66 profile image
Chris Shepherd

I've worked as a Programmer in finance for 20 years. In all that time I have never needed more than the most basic maths (+-*/ etc).

and the correct answer to any programming problem involving kangaroos is....Who cares ;)

Collapse
 
almostconverge profile image
Peter Ellis • Edited

I feel there are two questions here rolled into one.

How important is understanding the specifics of maths?

This depends a lot on the area you're working in. If you're working with maths (like in neural networks), you obviously need to know those quite well. Also, if you want a fighting chance with functional languages, you should know the theory behind them. And whatever you do, you must understand Boolean logic. But apart from the above, you can often get by without even undergrad level maths. However...

How important is understanding the mechanics of maths?

This is the key to all developers. In particular there are two concepts that you have to master with time: abstraction and laziness.

Abstraction is the lifeblood of software development, it's what enables you to identify the structure of a problem, and model it in code appropriately.

And by "laziness", I mean a very specific type of laziness that is shared by maths and software: when you think about it, the history of maths is the history of people finding easier ways to do increasingly more complex things. And the same is true for software: recognising that you're doing a repetitive thing and instead of doing it, using abstraction (and from that, automation) to make your life and job easier.

TL;DR: You may think the specifics of maths aren't important for your job, but the underlying principles absolutely are.

Collapse
 
rapidnerd profile image
George

I feel like it's always going to be topic specific. Some projects I've worked on have used very basic math and worked flawlessly, while having issues with being able to do math other projects I've had to ask people to help/do the math for me. A company I use to work for even hired 3 mathematicians because of the amount of math that was required.

Specific topics such as machine learning and neural networking will require a lot of it. The topics generally range from needing basic math, algebra and in some cases calculus.

I've always suggested to people to have some basic understanding of the topic that would be required even if someone else is figuring out the math side of things, that way when you come to look and work on it you're not completely lost.

Collapse
 
austinhardaway profile image
Austin Hardaway

I'm a graduating senior double majored in math and CS. I love math and CS and software engineering, but I do have to say that I can't really recommend that path to someone whose only goal is to become a SE/SD. For 90% of people most if the extra curriculum won't ever come up. The real benefit is having a different paradigm to approach problems with. That's great, but a Math degree is probably (definitely) not the most efficient way to achieve that and is totally doable through self study with only cursory looks at proof techniques. All in all it's really a matter of enjoying the subjects you are learning, IMO everything else will fall into place

Collapse
 
sreeprasad profile image
Sreeprasad

Please correct me if I am wrong but won't your answer print "No" for the following input (0,12,4,2).
Here x1 = 0, v1 = 12 and x2=4 and v2=2.

First Kangaroo x1 reaches 12 in 1 step & second Kangaroo reaches 12 in 4 steps.

But your solution will print "No".

I guess the question is should the both take the same number of steps to reach the common point.

Collapse
 
kalkwst profile image
Kostas Kalafatis

The requirement is to land on the same point at the same time ;)

Collapse
 
ocdanny97 profile image
štrudlokokole

I'm not an experienced dev, but judging by what the task is asking for an output (a simple binary yes/no), this is definitely the most efficient way to come up with the solution. (It honestly didn't even occur to me that you could solve it that way)

However, if the task was also to figure out at what exact second they would meet (or at least be the closest together), maybe a stepping algorythm wouldn't be such a bad idea. For instance, if the difference in distance between the two kangaroos becomes greater after one step, they're never going to meet. However, if the distance shrinks after the first step, the program should loop the steps until both kangaroos meet (distance being zero), or at least monitor when the distance starts increasing again, marking down the step before it started to increase (so we also have the lenght of the shortest distance between them, as well as the exact second that happened)

Hope this all made sense!

Collapse
 
damirtomic profile image
DamirTomic

There's a problem with websites such as HackerRank: they only test things that can be automated.

The tasks they give you must be formed in such a way that their solution can be quickly verified by a program. Meaning, the tasks must be defined explicitly in a unambiguous way.

For a specific input, your program must return a specific output. Logical thinking is an important trait but it is not the only factor in programming.

These tasks are written by skilled programmers. However, in real life, your client won't be an engineer who figured everything out beforehand. You will have to be flexible, use object design, refactor, improvise along the way and often, work as a team.

How will you gauge these skills? You need human analysis and commentary which takes money and time.

And yet, these sites teach people that the only important thing to know is algorithms. They don't say: "eh, we test a part of your skillset. The other, equally important segments are too much of a hassle for us to check".

Collapse
 
dzungnguyen179 profile image
Dzung Nguyen

Math is very important. It help us to make solution looks cleaner. I don’t agree with “good developer is not good at math”

Collapse
 
paveltrufi profile image
Pavel Razgovorov

Good Maths base is a must, but you don't have to be THAT good. Just some basic knowledge usually is enough. What you have to be good at is solving math problems 😀

Collapse
 
yashbhutoria profile image
Yash Bhutoria

This is the exact same problem that made me realise this thing.I always use it as example to my mentees.

Collapse
 
isaacleimgruber profile image
IsaacLeimgruber

I think everyone in IT should have at least an idea of what time complexity is. Beyond that, math knowledge is relevant or not depending on the subject