tags:

views:

6022

answers:

26

It seems that conventional wisdom suggests that good programmers are also good at math. Or that the two are somehow intrinsically linked. Many programming books I have read provide many examples that are solutions to math problems, or are somehow related to math as if these examples are what make sense to most people.

So the question I would like to float is: do you have to be good at math to be a good programmer?

+1  A: 

No. You do need to be good at logic though, which isn't exactly the same thing. Me, I'm great with the logic, but the numbers generally throw me for a loop. I can work it out, but it takes me longer to do the mathy bits.

Tim Sullivan
+4  A: 

The short answer is no. I think it's a bit of a myth but it's propogated because maths problems are usually well suited to being solved by computers.

So in uni/college, people will get maths problems that they need to solve in compsci subjects but what you will usually find is that the maths is actually harder to solve than the code that is needed to implement the solution.

Once you get into the real world, you'll increasingly find that the problems are largely solved for you, your job will just be to implement them in code.

lomaxx
+34  A: 

I think it depends on what type of programming you want to do. As far as being a programmer in the business world goes, I would say that the answer is no. You can become a great programmer without knowing advanced mathematics. When you do end up having to deal with math, the formulas are usually defined in the business requirements so it only becomes a matter of implementing them in code.

On the flip side, If you want to become a low-level programmer or say create 3D graphics engines, mathematics will play a huge role.

Daniel Auger
+4  A: 

It somewhat depends on what exactly you are doing, though it definitely can't hurt.

For example, someone who majored in Computer Science has got to go through a lot of math to get their degree. CS generally focuses a lot on algorithms and their correctness, proven through high-level math-style proofs. Many Universitie's CS programs are so close to their math program that a double major is only a few courses away. Even as a Software Engineering major, myself, I was 2 courses away from a Math minor.

However, that being said, a lot of the proofs, data structures, search methods, and algorithm correctness stuff that I learned hasn't really been put to direct use since I finished school. But it would be hard for me to say that it didn't at least give me a good foundation and better understanding of what I do at a low level.

Because no matter how you look at it, at the lowest level, everything you are doing boils down to math.

Adam Haile
+1  A: 

Depends. Enterprise CRUD (Create, Read, Update Delete) apps usually don't need exceptional math skill. On the other hand if you are designing algorithms a background in math will help and in many cases be necessary.

jms
+1  A: 

I think it obviously depends on what sort of programming you're talking about.

If you want to write the rendering engine for a video game, you're going to need stellar math ability to have any hope. If you want to develop data structures and sorting algorithms, math is very important.

If you want to develop websites and line of business applications, complex math really does not come into play that often (excluding the problem domain).

Either way, I think the most important thing is that it's never too late to learn.

Dave Ward
+4  A: 

No.

Much like most science disciplines, having a good understanding of maths concepts is going to be helpful, particularly when evaluating things like efficiency. But for most programming tasks your maths ability is only relevant if the problem you're solving is related to maths.

Computers are excellent at doing mathematics, so it makes sense that early computers were used extensively to do the 'grunt work' associated with a lot of complex maths work. A lot of software still does solve complex maths problems, in that case being good at maths will help you write a better program, but it's not what makes you a good programmer.

Reto Meier
+3  A: 

Usually, not in the sense that you need to know, say, calculus or trig equations to do most work. If you're doing heavy graphics/game programming, then yes. A famous math hack for Quake is a good example of this. However, the thinking that you have to get into while dealing with higher-level math certainly is applicable to programming; with programming, you are developing your own logic structure, your own functions, your own "proofs."

The only time I've run across math in my job (internal enterprise workflow and apps) is when I do some reporting apps that require knowledge of statistics, but that's only because it was directly applicable to requirements.

Chris
+16  A: 

You don't have to be good at math. However, you have to be good at logic, and problem solving. However people who are good at logic and problem solving are usually good at math also. I would say that it really depends on the type of math. You can be terrible at calculus (like me), and still be a good programmer (like me). But if you have trouble with Discrete Math and Set Theory, you would probably find a lot of aspects of programming quite hard.

Kibbee
+1  A: 

Ditto Tim. There are some areas, like 3D graphics, where you'll want to understand, for example, physics, but for the most part you can get by with just arithmetic and some simple algebra.

Bill Williams
+3  A: 

This is a very hard question to answer and will likely stir up a lot of debate.

One of the reasons why this question is so hard is that it partly depends upon what type of work you are doing. There is not a lot of math involved with most business applications, so you can get by with a solid understanding of algebra and business math. However, more advanced applications call for more advanced math and you start needing a solid understanding of calculus, linear algebra, and the like.

However, that is just one part of the equation in that you still need a certain degree of mathematics for just the practice of programming itself. It goes without saying that you need to be comfortable with logic to just be able to write a basic program as well as basic algebra. Looking a bit beyond just getting a basic program working though you need to have an understanding of certain aspects of discrete mathematics to be able to make determination as to what makes for a good algorithm to use for a given problem.

To get back to the heart of the question though. I personally don't think you need to be a mathematician to be a good programmer; however, I do think that you need to be comfortable with math to be able to be a good generalist programmer.

Rob
+1  A: 

I would say not necessarily. Certain programming disciplines (crypto, graphics, physics engines etc) would definitely have a clear advantage for the mathematically inclined, but I don't think a good understanding of differential equations would be particularly useful for web programming for instance.

Boolean logic is probably a requirement to be a good programmer, but it wouldn't surprise me if a lot of people who didn't achieve good marks in high school maths turn out to be good at programming.

Cebjyre
+1  A: 

Not maths as such, but arithmetic comes into play a lot.

Unless the application you're writing is heavily mathsey, then you don't need it to be a good programmer. If you're just starting out and want to get into games or graphics programming, then that can often be quite maths oriented.

izb
+2  A: 

I would say you definitely don't need to be good at math to be a good programmer.

My first job as a programmer was doing 3D graphics for B-52 and Cruise Missile mission planning. It was a math intensive application, but I really only needed access to people that were good/great in math. I didn't need to know the formula for computing great circle distances between two points. I did need to know how to convert the formula so that it worked in a programming language. The same with flight simulation. Boeing did all the math we just had to apply it.

That experience also helped me get a sense of who would be a good programmer and who wouldn't. The job had pilots and navigators taking a tour of duty as programmers and to help the programmers understand the needs of the mission. You could usually tell within a few weeks what pilots and navigators would be good at it. Math majors usually took to programming right away.

So I would say being good at math makes it more likely you will be good at programming, but I know a lot of good programmers that aren't so good at math.

bruceatk
+6  A: 

Almost everybody has answered: "do you need to know math to be a good programmer?" The correct answer to this is: "No, not really, but it helps," as many have already said.

But my interpretation of the question is "is there a strong correlation between mathematical aptitude and programming aptitude?" The correct answer to this is: "Yes, there is." If you struggle through algebra, geometry, and calculus, then you probably aren't very good at dealing with abstractions and/or thinking logically. If you're bad at math, you probably won't ever be a great programmer. (Not that you shouldn't try.)

Chris Conway
A: 

I disagree fairly strongly with Daniel (to a point). To be a capable with the programming languages, api's and tools that you use, it strong math skills aren't necessarily required. However, if your goal is to go beyond the level of coding to other people's specifications being able to apply math and more complex algorithms to a problem (I consider these to be very similar) will take you a long way toward that goal.

Now for the why. In my experience, it's usually not hard to come up with programming solutions to many propblems that meet the requirement of producing the required output and keeping to a few restrictions. Where the math will really help you is when you have to take an existing solution and make drastic improvements to it. For example, if you need to write you own text comparison code, it isn't hard to use the search text to generate a simple regex to account for some spelling differences, but if you want to be able to emulate the behavior of Google Suggest, you need to understand algorithms like Soundex, Levenstein Distance and others. For a more mathamatical problem, consider a cache for keeping commonly used objects in memory instead of hitting the DB every time. How can you generate hash values in such a way that two objects with trivial differences have the same hash value?

At the end of the day though, the type and amount of math you need really depends on the field you're in. If you working with computer graphics, strong calculus and algebra skills are pretty important, but developers of financial software can probably get manage without. On the other hand, in any application where you have to deal with floating point arithmetic, having a strong understanding of number theory is a necessity, otherwise you'll constantly be faced with running totals that no longer add up correctly (due to rounding, truncation, and number representation issues).

Dana the Sane
+1  A: 

Yes, definitely.

Even run of the mill business programing requires some skill at math.

Run of the mill business programing requires database skills. Being a good database programmer requires an understanding of how databases work, and what the algorithms are that the query processor uses when it translates your queries. Without an understanding of limits and derivatives (or even the basic understanding that the line y = x intersects the line y = x^2 twice), it is not feasible to accurately compare a hash-match inner join query plan vs a nested loop join query plan.

Also, a good programmer can work in just about any domain, provided that they study up a bit: games, simulation, embedded development, compilers, operating systems, web stuff, databases, etc. Being able to do all those things (or more accurately being able to quickly learn how to do all those things) requires a decent amount of mathematics background.

I'd say that one should have had some experience at some point in time with the following:

  1. 3 Semesters of Calc
  2. Diff Eq
  3. Linear Algebra
  4. Modern Algebra
  5. Basic probability,counting, and statistics
Scott Wisniewski
+22  A: 

I'm going against the grain and saying yes, you need a math mindset. Most people think of math as doing arithmetic or memorizing arcane formulas. This is like asking if you need perfect spelling or an extraordinary vocabulary to be a good writer.

Writing is about communication, and math/programming is about the process of clear, logical thinking (in a way that you can't make mistakes; the equation doesn't balance, or the program doesn't compile). Specifically, that logical thinking manifests in:

  • Ability to estimate / understand differences between numbers: O(n^2) vs O(lg(n)), intuitive sense of KB vs MB vs GB, how slow disk is compared to RAM. If you don't realize how tiny a KB is compared to a GB you'll be wasting time optimizing things that don't matter.
  • Functions / functional programming (is it any coincidence that the equation f(x) = x^2 is so similar to how you'd write that method? The words "algorithm" and "function" were around in the math world far before the first computer was born :-))
  • Basic algebra to create & reorder your own equations, take averages, basic stats

So, I'll say you need a math mindset, being able to construct & manipulate mental models of what your program is doing, rather than a collection of facts & theorems. Certain fields like graphics or databases will have certain facts you need also, but to me that's not the essence of being "good at math".

kurious
A: 

I found an interesting article and ensuing discussion regarding this question:

Slash7: Got Math?

Charles Roper
+3  A: 

The fundamental concept of maths is the following, devising, understanding, implementation, and use of algorithms. If you cannot do maths then it is because you cannot do these things, and if you cannot do these things then you cannot be an effective programmer.

Common programming tasks might not need any specific mathematical knowledge (e.g. you probably won't need vector algebra and calculus unless you're doing tasks like 3D graphics or physics simulations, for example), but the underlying skillsets are identical, and lack of ability in one domain will be matched by a corresponding lack of ability in the other domain.

DrPizza
A: 

I say this as someone who is neither great at math nor necessarily a remarkable programmer, so perhaps you can take my opinion with a little grain of salt.

When you know continuous and/or discrete math a bit better, you'll find that problems you encounter benefit from that knowledge. Similarly, when you at least understand how algorithms like breadth first search work, you'll discover applications for that more readily than before you understood it. Some problems that seem intractable when you only know about simple data structures like arrays and linked lists suddenly seem relatively simple when you understand a little bit about graph problems.

The point is, almost all kinds of knowledge will make you a better programmer.

I'm not sure that the inverse is true: that you MUST be good at math to be a good programmer. But I suspect that the difference between good and great may be a question of math skills.

Steve Yegge's blog has at least one argument in favor of shoring up one's math skills. It's an interesting read.

Basically, almost any kind of domain-specific expertise can be useful as a programmer. I probably wouldn't be in this industry had it not been for my German and Japanese skills; it was a question of right place, right time, right foundation. I suspect knowing even trivia-level details about biology (ant colony optimization?) can open your eyes to more ways of solving problems.

JasonTrue
A: 

Pretty much repeating what everyone else has said. The more graphics you are doing the more math you will need. 3D stuff gets kinda hairy with the trig and matrix stuff, but like everything else, you learn the idioms and you're good to go

Scott Evernden
+1  A: 

Math is more than just formulas. Understanding some mathematical principles about set theory is very useful to grasping complex concepts on type systems, as is understanding complexity a paramount to efficient data structure usages.

Graph theory is also extremely useful, as many programming problems can be modelled by a graph. I was very astonished, as I was developing a business application, to find out that the shortest path theorems were providing an elegant solution to a thorny problem that I had!

small_duck
A: 

Short answer: It depends on what kind of programming you're doing.

Longer answer: If you mean specific mathematics courses that you do, then it very much depends on what kind of programming you're doing. Some kinds will be useful to all programmers (see Concrete Mathematics by Graham, Knuth and Patashnik, for example), whereas some can get by without using, say complex analysis (which I have used in programming).

More generally, the kind of logical thinking that mathematics needs, particularly in finding flaws in bogus proofs (e.g. that 1=0) hones the kind of thinking needed in debugging.

Personal suggestions:

Essential:

  • Calculus - general purpose. More advanced courses in it may be useful (e.g. complex analysis is used in electronic engineering).
  • Statistics - general use, have used it personally in my career.
  • Logic - converting logical expressions into equivalent but simpler expressions, checking the validity/nonvalidity of a proof.
  • Computability theory - see proof of Halting Problem being unsolvable for Turing machines - you may find yourself trying to solve something equivalent to it some day, then rewrite the code to solve a possible task, depending on the domain.
A: 

I am pretty bad at general math. However I am very very good at logic and problem solving.

It helps that I started programming BASIC when I was like age 10 though.

I consider myself to be a "good" programmer. I know however that I will probably never write a 3D engine or face recognition algorithm or anything like it. And that is the key. Everyone has limitations. I know there are certain areas in software that I will never be able to go. But likewise those people that are exceptionally good at math aren't always the best software engineers/architects either.

Just last week we interviewed a guy that could probably write you a face recog' algorithm in the space of a week. However he knew nothing about design patterns or architecture. Nor did he display any interest in them at all.

So no. I don't think you need to be "good" at math in order to be a "good" developer. There are many different types of developer.

NathanE
A: 

If you are not very good at math then your answer will undoubtedly be "no, math skills are not required". If you are one of the small percentage of people that actually know math and use it everyday, then you realize how valuable your math skills are and how they enable you to quickly develop routines. You will not spend countless hours debugging using trial and error methods. Your functions and classes will be "reduced" allowing for more complex functionality. Given enough time and motivation, anyone can program. Will the code that person writes be any good?? I guess if it works, right?

Bottom line. A programmer with good math skills will be a far better programmer than the one who lacks. They will be much more productive and will save the company oodles of money in development costs, both in the present and future when the application needs to be expanded upon.

The most basic program is an exercise in Algebra. If a programmer does not recognize this, the result is code that is not reusable. You get lots of repetitive "almost the same" code. Another word for this type of programming is "non-scalable"!

"Hello, World!" is an exercise in algebra? :)
Will Mc