I <3 Steve McConnell*
Coding Horror
programming and human factors
by Jeff Atwood

April 1, 2009

Should Competent Programmers be "Mathematically Inclined"?

One of the more famous Edsger Dijkstra quotes is from his 1972 Turing award lecture, How do we tell truths that might hurt?

Besides a mathematical inclination, an exceptionally good mastery of one's native tongue is the most vital asset of a competent programmer.

Note that he specifically says native tongue, not English. Which makes me wonder why all of Dijkstra's most important writings were in English, not his native Dutch.

But I digress. Let's consider the first part of the Dijkstra quote. Should competent programmers be "mathematically inclined"? It might be instructive to think of programming as a form of mathematics, at least for one reason: to resist localization. Although there have been attempts to create localized programming languages, as far as I know, nobody has ever tried to localize π or the number 3. They're universal. So in that sense, programming languages bear a vague, passing resemblance to mathematics. Learn the symbols once and use them everywhere in the world, no matter what your native tongue is.

On the other hand, I have not found in practice that programmers need to be mathematically inclined to become great software developers. Quite the opposite, in fact. This does depend heavily on what kind of code you're writing, but the vast bulk of code that I've seen consists mostly of the "balancing your checkbook" sort of math, nothing remotely like what you'd find in the average college calculus textbook, even.

{
  i = j++ / (x + v);
}

Not exactly the stuff mathletes are made of.

I never understood the desire to formally equate skill at mathematics with skill at programming. While being a math wonk certainly won't hurt you as a programmer, it's very hard for me to draw a direct line from "good at math" to "good at programming". Like Rory, I believe that software development requires some markedly right-brained sensibilities.

When I was growing up, I remember hearing people say things like, "If you like computer programming, then you'll love math." I always thought that these people were absolutely nuts. While there is something intrinsically similar about certain types of math and computer programming, the two are different in many more ways than they are similar.

With math, and I'm not talking about the crazy number-theory math philosophy "Do numbers really exist?" side of things, but with the applied stuff, there are correct answers. You're either correct or you're incorrect.

With coding, the best you can hope for is to do something well. With so many different ways to effect a single outcome, it's up to some very right-brained sensibilities to determine if you've met your goal, as there isn't anybody (except [another more experienced developer]) who can tell you if you're right or not.

If you ignore your right brain, and I'm talking generally about abstraction and aesthetics, then you can slap some code together that might work, but it also might be one hell of a maintenance nightmare. If you focus only on the right brain, you might have something that works, but is so utterly inefficient and personalized that you're the only person on Earth who could make sense of the code and maintain it.

All those caveats aside, people still advocate the idea that math alone has the power to make you a better programmer. Steve Yegge makes the best case I've read for the programmer-mathematician, with his five points:

  1. Math is a lot easier to pick up after you know how to program. In fact, if you're a halfway decent programmer, you'll find it's almost a snap.

  2. They teach math all wrong in school. Way, WAY wrong. If you teach yourself math the right way, you'll learn faster, remember it longer, and it'll be much more valuable to you as a programmer.

  3. Knowing even a little of the right kinds of math can enable you do write some pretty interesting programs that would otherwise be too hard. In other words, math is something you can pick up a little at a time, whenever you have free time.

  4. Nobody knows all of math, not even the best mathematicians. The field is constantly expanding, as people invent new formalisms to solve their own problems. And with any given math problem, just like in programming, there's more than one way to do it. You can pick the one you like best.

  5. Math is... ummm, please don't tell anyone I said this; I'll never get invited to another party as long as I live. But math, well... I'd better whisper this, so listen up: (it's actually kinda fun.)

To me, this reads like a broad recipe for becoming intellectually curious and building skill at solving abstract problems. Important programming skills, to be sure, but not necessarily exclusive to the study of math. If math is your preferred way to sharpen your saw, then have at it -- but it's hardly the only way.

I recently received this email:

I run a small (4 people) web dev shop and I'm finding that younger coders haven't had the pleasure of writing assembler or managing without library functions. I've always found strong math skills to be one of the most useful skills for coding, and when one has Google and a massive library of functions, one doesn't have to be good at math to get things working, until it either breaks, has edge cases, or brings out OS or library bugs.

Some quick examples: simplifying tricky equations to determine array indicies or memory offsets; trigonometry to help with physical calculations; mental hex/bin/dec conversion; logic equalities such as DeMorgan's theorem.

He's got the right idea; if we're going to talk about math, let's get out of the abstract and into the specific. Let's talk details. Examples. What could be more math-y than that?

What code have you personally written where a detailed knowledge of math made your work easier? I can think of some broad categories. Writing a 3D game. Or a physics simulation. Or low-level image filters. Or compression algorithms. The list goes on and on. But if you're in those situations, you'll know it.

Maybe I'm a hopeless optimist, but I think most programmers are smart enough to learn whatever math they need just in time to attack the problem at hand.

Posted by Jeff Atwood    View blog reactions
« The Ugly American Programmer
The Eight Levels of Programmers »
Comments

No one has ever tried to localize the number 3?

How about the Chinese character &#19977;? (That's three parallel horizontal lines, for those of you whose browsers aren't showing the character.)

graham on April 1, 2009 5:50 AM

PI was nearly localised in 1897 when the Indiana House of Representatives unanimously passed a bill stating that ëa circular area is to the square on a line equal to the quadrant of the circumference, as the area of an equilateral rectangle is to the square of one sideí - which I think puts PI = 4!!

I think that maths and programming are intrinsically linked although you can excel at either without necessarily being good at the other. I think you're spot on when you say that programmers lean Just In Time - which suggests that as a breed, we're matahematically capable, or predisposed, but don't necessarily develop that trait.

It's a little like being fit, but not playing specific sports until you need to.

JakeyC on April 1, 2009 5:59 AM

uh, wasn't the calculus localised - germanys leibnitz vs. britains newton?

schnalle on April 1, 2009 6:02 AM

I agree. I view programming as more of a logic and artistic endeavor than a mathematical one. Unless you are writing compilers, heavy 3-D graphics programming, or low level programming, basic mathematics is more than capable of carrying a programmer forward. Most business programmers (and I'm sorry, that's most of us) just need basic math skills to make sure calculations are correct. Programming is a way of thinking, not something that you have rules for everything as in mathematics. I think language and thinking skills are infinitely more important than math skills. Documentation and clearly written code are much more important than advanced theory and calculus.

jeff on April 1, 2009 6:04 AM

Dijkstra talks about the old (golden) age of programming where programming required very good mathematical skills.

A good programmer those days needed to be skilled in designing new algorithms (because there were not much downloadable libraries), and optimize their code to fit into whatever meagre memory they were provided with.

If you are talking about web development kind of programming, of course you need not be very good at mathematics for that. But I do not consider web development anywhere near REAL programming.

These days we are just combining some already availbale modules and (Voila!) you have a new application. This readucec the need for any deep mathematical knowledge. I think we are becoming more of desingers that programmers. We take all those pre-built libraries and then neatly arrange them together.

Niyaz PK on April 1, 2009 6:06 AM

"Good at Math => Good a Programming" is not from knowing some specific math bits. It's the thought processes that math requires (i.e., logic, correctness, completeness). If a person is good at math (any math), then he MUST be capable of thinking a problem through logically and finding/developing an algorithm to solve it. That's the same skill set required for programming. Also, see this:

<a href="http://en.wikipedia.org/wiki/Claude_Elwood_Shannon">http://en.wikipedia.org/wiki/Claude_Elwood_Shannon</a>

for a bit of information on the linkage between Boolean algebra and computers.

David A. Lessnau on April 1, 2009 6:08 AM

Early on I often felt pretty ashamed about being a software engineer and not being great shakes at math, but I think you're absolutely right when you say that programming involves a lot of right brain activity, too.

I feel that there are generally two extremes with programmers, the guys who are good at math and know how everything works on a low level, and the guys who are more "artsy" and are good at design and abstraction. IMHO you need both types (and a few in between) to make up a really great team. They tend to provide checks and balances for each other (even if the math guys tend to look down on us right brain types:).

Great article!

Eagan on April 1, 2009 6:09 AM

Having the knowledge of doing something and actually using it are different things. I like to know that if I ever need a certain formula or simplified way of doing something that I can do it. The lower level math is forever planted in my brain, therefor it is easier for me to use it more often than the higher level.

I am just a CS major in college (freshman), so a lot of our assignments are based more toward using a more efficient way of doing something that we have already done.

Tyler on April 1, 2009 6:13 AM

Mathematics is the language of the universe. It is the ultimate programming language. If you have ever spent anytime in advanced mathematics, ( real analysis, modern algebra, etc ) you quit plugging and chugging with formulas, you begin to organize and construct proofs. This exercise not only requires a sharp analytical mind, but the good proofs always involve a great amount of creativity. The elegant solution is always beautiful and concise. Compare this to programming. The easy solution is typically longer, uses less advanced maneuvers ( theorems if you will) and is just plain old ugly. The ability to write clear and concise code is a one-to-one function with the ability to construct elegant proofs.

Ryan Smith on April 1, 2009 6:14 AM

I don't have much formal maths education, which is probably why, when I was writing an Asteroids clone in Flash a few years back, I wrote my own insanely complicated functions for calculating directional velocity instead of using SIN and COS. I also get a bit lost around maths-like terminology such as "arbitrary complexity" or "O(logn)".

Mark on April 1, 2009 6:15 AM

not math but logic is the key.

Keng on April 1, 2009 6:16 AM

> I was writing an Asteroids clone in Flash a few years back, I wrote my own insanely complicated functions for calculating directional velocity instead of using SIN and COS

fantastic, LOL! This supports Steve's position -- it illustrates that you'd need *enough* math background to at least know in what general direction you should be looking. And save yourself some coding time and pain to boot.

Jeff Atwood on April 1, 2009 6:17 AM

When Dijkstra mentionned a mastery of the native tongue as an asset for a programmer, he didn't mean that you need to express yourself in it. He just meant you need to master a tongue. Why ? Because language is left side brain. Good programmers are often good at word games (in their native tongue). Just because you need something doesn't mean you actually use it. It means you need it because while you developped it, you also developped a lot of other side proficiencies.

In mathematical inclinaison, I can understand that too. People remotely good at mathematics can understand the abstraction and the formalism present in a computer language. Also, it helps a lot if you want to understand shortest path algorithm, image processing and stuffs like this.

I worked on ultra-large scale websites (100k servers) and sometime you cannot just "add hardware" (to quote you). 100k servers is not something even remotely cheap. You need to improve your algorithms to improve performances, and to do this, you need proper algorithm understanding, which is usually developped with math (graph and number theory).

Eric on April 1, 2009 6:18 AM

To me, anything interesting at all involves heavy math. Maybe it's just me but programming web or enterprise apps just isn't very intellectually stimulating.

chris on April 1, 2009 6:18 AM

@Niyaz PK: "But I do not consider web development anywhere near REAL programming."
That's just discrimination.

Lucian on April 1, 2009 6:19 AM

I think you hit the nail on the head with the Just in Time concept. Oh, I need calculus to run this machine? OK, I can learn enough to make it happen.

"Don't tell the customer" I only learned this yesterday :)

Practicality on April 1, 2009 6:20 AM

The mathematics I need for my day to day work are simple linear algebra; no calculus, and no abstract numbers either... I see the value of mathematics for programming (and vice versa) in the transition between abstract description and spcefic examples.

For many pupils, the most difficult part of a math test are math story problems. They give you a story, a specific example. Your task is to transform it into an equation (or a set of equations), an abstract description. Once you have done that, solving the equation is usually trivial.

In Programming we often encounter similar situations: We get specific examples of what the software should be able to do ("allow me to add remarks to each order"), and it is our job to work out how this will be reflected and implemented in the application (add new text field REMARK to ORDER object, add new edit field in the GUI etc).

If you found it easy to solve those story problems back in school, I bet that you are doing well in the abstractions needed for developing software.

Treb on April 1, 2009 6:20 AM

"Maybe I'm a hopeless optimist, but I think most programmers are smart enough to learn whatever math they need just in time to attack the problem at hand."

I would dispute that. I have observed that learning math concepts is not just like learning a piece of information - it takes time, sometimes even years for your brain to familiarize with mathematical concepts.

Also, very often there are mathematical tools you could apply for a given programming problem - if only you knew about the existence of these tools. I'm not talking about 3D rendering engines here but more like everyday business applications. Understanding propositional and predicate logic can help a lot implementing common business rules. And it's not a complex concept at all but still it takes some time to figure it out and it is a part of CS undergraduate programmes for a reason.

DrJokepu on April 1, 2009 6:24 AM

Basically, good knowledge of math will allow developers to better optimize their code, this is quite important I might say...

Dudi on April 1, 2009 6:24 AM

I agree with Steve Yegge in this: while those "balancing the checkbook" programs don't require a heavy math background, there are many, MANY problems with you won't solve without a math background (well, maybe you can get a library somewhere which does what you want, but that's not the point of the article). Right now I'm thinking shortest path, maximum flow, anything about physics (and yes, most games fit here, unless your game takes place in a world without gravity, ie minesweeper), and so on. However, even beyond those kind of problems (question: if I can't do any of those things, but I can write a checkbook-balancing program, am I still a competent developer?), programming in itself is writing algorithms, so programming doesn't require math, programming IS math (those who study first order logic love to brag about that).

I don't think anyone will like programming without some math inclination, even without knowing about it. That said, software development and programming are not precisely the same thing. A programmer must be able to take a problem and write an algorithm to solve it, but a developer must also stick to a methodology of work (design patterns, abstraction, reuse of code, source control, etc). You can do that second part with little more than a lot of common sense, I think.

Martin on April 1, 2009 6:26 AM

The type of math you are referring to and the type that Dijkstra is referring to are different branches. You given an example of algebra, but Edgar is referring more to the topics covered in Discrete Mathematics, which include things like graph theory, set theory, O-notation, etc. Basically, the various topics that enable developers to analyze existing algorithms and data structures, improve them, or develop their own.

"I view programming as more of a logic and artistic endeavor than a mathematical one"

This statement is highly inaccurate. Logic is a topic within math, and creativity is needed in proof construction, a core skill.

Delmania on April 1, 2009 6:26 AM

Whats this correct way of learning math then? a blogpost on that would be useful?

Tom J Nowell on April 1, 2009 6:26 AM

Wow..Today, I received a copy of Concrete Mathematics that I ordered from Amazon and today is also the day you come up with this interesting blog post. I was stunned to find no mentions of Knuth here ;)

Arvind on April 1, 2009 6:26 AM

jeff -

Hi, please dont get mad cause im asking about steve, but:

>They teach math all wrong in school. Way, WAY wrong. If you teach yourself math the right way, you'll learn faster, remember it longer, and it'll be much more valuable to you as a programmer.

what is the "correct" way then? I remember spolsky saying something like this as well on one of your podcasts.

theman on April 1, 2009 6:27 AM

Calculus is most definitely *NOT* the kind of math that helps programmers, and I don't think Dijkstra or any of the other math advocates was referring to calculus-type maths in those quotes. I wasted quite a lot of time in required calculus courses at college, and I find myself wishing for a greater knowledge of discrete maths fairly oftenóintro to combinatorics was not enough.

Hank on April 1, 2009 6:29 AM

Personally I don't trust a programmer that is a lousy chef.

hesnews on April 1, 2009 6:29 AM

I think all programmers should have a good understanding of some basic statistics, especially things like probability distributions, standard deviation, Chebyshevís Rule. I think its not only the key to understanding data your program might work with, or how to best display widely ranging business data, but also might help with project decisions. I've sat in meeting where people will spend hours discussing how to approach a problem without even getting a handle on the data.

Also, a math background might help you to tackle algorithms that are in books like 'Programming Collective Intelligence'. Sure, you can just apply algorithms blindly, but understanding it does make you a more competent programmer.

kailden on April 1, 2009 6:30 AM

@theman

Yes. Somebody teach us the correct way to learn math!

I remember those shows where the math guy could do insane calculations faster than a calculator. He also said the same thing. We learn it wrong.

One of his tricks was adding the larger numbers first and then doing the small numbers and figure out the carry overs. That one helps me out often. But I am sure there are about 1000 other ways of relearning math we need to learn to actually be proficient with it.

Practicality on April 1, 2009 6:30 AM

An application I worked on recently involved displaying a map. You need a simple amount of geometry/mathematical capability to work out how to convert from world co-ordinates into screen co-ordinates, but I definitely have co-workers that struggled with that.

I didn't even use matrices for the transformations, and we didn't include rotations, just simple translations and scaling.

The programmer/mathematician argument for me goes like this:

You need a certain amount of creativity to create a solution to a problem. However, you need to think like the machine when trying to debug code. I guess this is less mathematical and more having a solid scientific method, but that amount of times I've seen co-workers debug by voodoo is staggering.

Ever had a co-worker state "That just doesn't make any sense" when looking at a program's behaviour? Well, it must make sense, because the computer does exactly what you wrote. You just haven't written what you meant - and writing down exactly what you mean is key to mathematics.

Paul Smith on April 1, 2009 6:31 AM

I find the Math/Programming connection revolves less on the application of mathematical principles and more on the ability to develop a simple and direct solution to complicated problems.

Blob on April 1, 2009 6:33 AM

Several projects. One was bridge design software (helped by the fact that I was a Civil Engineer to start with), where I had to calculate bending moments and do structural analysis. One which I've just finished included reports containing statistical calculations. Again very useful.

You're right in that certain areas of maths are not relevant to the average programmer (see my experience above), but certain areas are extremely important (boolean logic, set theory). These are part of mathematics as well.

Matthew Farwell on April 1, 2009 6:33 AM

Apologies for double-posting, but I had another thought: don't confuse mathematics with arithmetic.

Paul Smith on April 1, 2009 6:34 AM

Sure, good programming requires a sort of artistic flair as well as the base logical thinking patterns and ability to construct correct algorithms (you've got to come up with those algorithms in the first place, after all).

The thing is, maths requires that as well. The creative side of programming is not something it requires that's different from maths, it's a commonality between the two.

I may be affected by my own background in formal programming language research, but I see certain mathematical skills as being the same as programming skills. I can't imagine being able to do the coding I do every day as effectively without the maths I know. I'm not talking about school algebra, solving quadratic equations, differential calculus and all of that. I'm talking about logic, proof construction, domains and codomains, mathematical theories of functions and things like that. What better way to describe formally how a function should operate than in the language at the heart of the universe?

The first time I seriously consciously used mathematical knowledge while programming was in a summer job while I was an undergraduate, where I constructed a mathematical expression of the algorithm we needed (we were making a data structure which was a kind of ordered list requiring particular guarentees on inserts that nothing we already had would provide), proved that the algorithm was correct, then wrote the PHP equivalent (I'm sorry, I was desperate for money) and proved that was also correct.

No bugs.

Maths works!

MattW on April 1, 2009 6:34 AM

April Fools, right?

Math is totally required for programming.

Maybe you didn't need to be formally educated in it, but you use mathematical principles all the time.

Graph Theory - invaluable for networks
Probability theory - you use this when making performance decisions. Maybe you do it intuitively but the concepts are the same.
Discrete Math - lots of problems in computer science are related to discrete math.

I've had to use math to prove things to management, such as the pigeonhole principle, which I used to explain to someone how hash codes do not contain as much information as the original data.

When you're developing a business application some of the hard math is already done for you by the people who wrote the library code you use. But if you want to do multi-variable usability testing of your app you need to do statistical analysis. The same goes for fuzz testing or even unit-testing: you need to limit the size of your test yet still get meaningful results. That's math.

Mr. Shiny & New on April 1, 2009 6:35 AM

I support Chris. With business/web development the hardest part is understanding your customer right. It's much more interesting to understand universal mathematical properties that are valid forever and throughout the entire universe.

adrian on April 1, 2009 6:35 AM

Although I won't say math helps per se but in my case begin great at math has helped me greatly. Especially solving complex sets of equations. Thats essentially what programming is. Its one big complex equation. It may be constructed with some very simple pieces. The biggest problem I see is that those who aren't that great in math don't seem to see the big picture. How everything fits together. Some do eventually get there but it takes them much longer than those with a strong math background. But then again this is just what I have observed.

Doug on April 1, 2009 6:36 AM

I think the ability to formulate your ideas clearly is the essential programming skill. Math is one discipline that forces you to do this; writing a five paragraph essay is another.

The essential skill I find a lot of programmers don't possess is the ability to answer the question "what does your program do?" in one sentence.

Most programmers respond to the question by detailing HOW the program does what it does i.e. "Well, first I build an array and populate it . . . blah blah blah". They can't clearly say WHY the program exists i.e. "The function calculates the final interest rate for a loan application."

Programming is structured communication.

tberthoff on April 1, 2009 6:37 AM

I'll second "word problems" and "knowing enough to know where to look".

awh on April 1, 2009 6:38 AM

I have seen competent programmer with very low math skill, and vice versa, good math guys unable to write a simple piece of code.

Nevertheless my own experience still advocate for a strong correlation between the 2 topics. I love programming and used to practice a lot math some years ago, and I am still emotionned by a neat algebra theorem.

Every single programming hour, I can feel that relentlessly chasing the buggy case is very similar to me, than when trying to challenge with counter-examples a math demonstration to see why it is working and can't fail. As math, programming is about caring about all details because any detail can make the entire edifice collapse.

Also an elegance piece of code might require some time to be fully understood. You then realize that any refactoring would make it worse. The same can be said from an elegant math demonstration. IMHO Programmers and Mathematicians are both looking for something elegant.

Beside this, I use some pure-math while coding NDepend, a lot of graph algorithm but also some tricky polynomial things, especially to increase performances and do some nice UI related things.

Patrick Smacchia on April 1, 2009 6:39 AM

I really hope I'm not falling for a big April Fool's Day troll. :-) In Stack Overflow podcast episode 39 you addressed the question: "Do programmers really need to know math?", and your conclusion, in a word, was "no". This blog post is a good follow-on to that discussuion. I hate to make a symantic argument, but I think your definition of math is too narrow. Fundamentally, all software is math and all math is software.

If the question were posed, "Do all programmers really need to know calculus?", I would agree with you and say no. Likewise for trigenometry, geometry and plenty more obscure branches of math. However, I think it is very important that people realize that software is math. Everybody recognizes Quicksort as an algorithm, and therefore math. But your little if-then-else statement is also an algorithm. Every piece of software is an algoritm. Microsoft Word is an algoritm for translating clicks and keypresses into documents.

It may seem that I am quibbling, but this has profound public policiy implications - specifically around the patentability of software. At least one of the following three statements are false:

1. Software is math.
2. Math is not patentable.
3. Software is sometimes patentable.

Right now, case law defines the second and third statements to be true. However, the first statement was proven to be true - mathematically - back in the 1930s with the lambda calculus. The statement "software is math" is true - not in the "3 out of 4 doctors agree" way, but in the "3 + 1 = 4" way. No law can change that, in the same way that no law can redefine pi as equal to three. So what we are left with is bad case law.

The subset of math that they teach in "math class" does not overlap 100% with the subset of math that most developers employ daily. That might be a less effective sound bite than "Programmers don't need to know math", but as a programmer I like my statements to make mathematical sense. :-)

Neal Lindsay on April 1, 2009 6:41 AM

Re: Mastery of native tongue - Intelligence and dyslexia etc. aside, there's a distinct correlation between grammatical ability and programming ability. Same brain wiring, IMHO. If you doesn't do grammar good, you is having not many funs with syntax.

Re: pi = 4 - wasn't that religionists pushing that through? (sure sounds like it - take the easy answer instead of leaving the difficult question open :) )

Schmoo on April 1, 2009 6:42 AM

There is an interesting article here http://www.maa.org/devlin/devlin_10_00.html about why math is good for programmers. The argument is basically that doing math teaches you to work with abstractions, something that is also needed when programming.

ìBut software engineering is all about abstraction. Every single concept, construct, and method is entirely abstract. Of course, it doesnít feel that way to most software engineers. But thatís my point. The main benefit they got from the mathematics they learned in school and at university was the experience of rigorous reasoning with purely abstract objects and structures.î

Henrik Warne on April 1, 2009 6:46 AM

Math is just as much about proofs and logic as it is about pushing numbers around. Math is also about being able to look at a problem and select the appropriate tool from a very large toolbox in order to reduce or change the problem. You then select the next appropriate tool and iterate. Sounds like programming to me.

David Dollar on April 1, 2009 6:47 AM

You're missing the point Jeff.

Functional programming helps you, not because you're writing functional programs, but because it helps you think differently.

Mathematics does the same thing.

Michael Reiland on April 1, 2009 6:48 AM

P.S.: I bet that you use a lot of set theory when you're writing Stack Overflow.

Neal Lindsay on April 1, 2009 6:51 AM

As a citizen of the great state of Indiana, yes, it's true, we once localized pi (*shame*). Also, when I took AP physics in high school, we used 9.8m/s^2 for the acceleration due to gravity, but the non-AP kids used 10 because it was an easier calculation. I was going to mock them, but I just looked it up to make sure I was remembering it was 9.8, and I see it's actually 9.80665 m/s^2 according to wikipedia. So I guess both groups localized it...

jj33 on April 1, 2009 6:52 AM

A distinction between programming and computer science is necessary for this discussion. Historical quotes might confuse the topic a little bit because of how far the two have diverged in the modern day. And then even within programming there is such huge variation in the nature of endeavors. Programming might mean writing macros in VBA to one person while it means writing numerical approximations to QED problems in C to another.

Since the usage of programming is so vague, hard and fast rules about programmers seem futile at best.

Ryan Shannon on April 1, 2009 7:00 AM

I agree with Herik, it helps with abstractions.
But now that I work developing games it has helped in a bit more concrete way.

But my opnion is biased as I have a bachelor degree in applied math.

Vinicius on April 1, 2009 7:01 AM

I agree that "most programmers are smart enough to learn whatever math they need just in time to attack the problem at hand.". But, what I've found several times is that there are many who are not willing to do that extra effort (even though they are able to)... And that's what's hard to deal with! But then again, most of them don't fit the "compentent programmers" category you've specified in the post title!

Bruno Marques on April 1, 2009 7:02 AM

Anyone who programmed Scheme or StandardML programming IS a type of applied math. A least for discrete values of math so to speak ;-)

Jens on April 1, 2009 7:03 AM

Math is hard. Let's go shopping!

Barbie on April 1, 2009 7:03 AM

Prediction:

Programmers who consider themselves "good at math" will proclaim that math skills are critical to being a good programmer.

Programmers who consider themselves "not good at math" will proclaim that math skills are irrelevant to being a good programmer.

Vance on April 1, 2009 7:04 AM

Math is more than just numbers. There's mathematical logic (for instance first order logic, from which most modern languages are derived); there's discrete math (you know, that boolean logic stuff we somtimes use; or for analyzing algorithms); there's set theory (a basic concept for most graphing problems, e.g. minimum spanning tree); there's computability theory; etc. etc. etc. etc.

Yes, to be a good programmer you <em>do</em> need to be mathematically inclined. Or perhaps better put: to be a programmer who isn't just doing the same repetitive CRUD operations in different forms all day, you need to be mathematically inclined.

There's a lot of waxing poetic about how programming is more an art than a science, and resistance to calling programming (or computer science as a whole) a mathematically-based science. The fact is it <em>can</em> be both. The golden ratio is an incredibly important artistic notion, but has its basis in math. Just like <em>all</em> the constructs of our field has its basis in math. There is still plenty of room for creativity, and you can approach it artistically for sure. But you can't rightly treat programming as an Art until you've mastered the <em>mathematically based constructs</em>: when you grok the mathematical and syntactical structure of a language, <em>then</em> you can start to be a artist. Not before.

So I would say that Dijkstra is correct.

Seinberg on April 1, 2009 7:05 AM

You've got it all wrong. It's not that specific math tools are useful in programming, it's that math and programming flex the same mental muscles.

<i>To me, this reads like a broad recipe for becoming intellectually curious and building skill at solving abstract problems. Important programming skills, to be sure, but not necessarily exclusive to the study of math.</i>

Intellectual curiosity is certainly universal, but solving abstract problems is the exclusive domain of math. Anywhere else you might think you're solving abstract problems, they can (and likely should) be represented with math.

As for there being no right answer, I think you've been writing too much javascript. There may be no correct overarching "way" to solve problem X, but individual statements, lines, modules, and ultimately executables either work, or they don't. Compilers are, if this is possible, <i>more</i> pedantic than formal math. Both math and programming benefit from an ability to think, speak, and write in a highly specific and precise manner, and so doing one trains you for the other.

Noah Yetter on April 1, 2009 7:05 AM

I'm constantly surprised, that math is such useful in daily programming job. And my current job is in big "enterprise" company writing business logic in Java, so I did not think it would be like that. Still, I'm happy, the more math the less boring stuff.

Last time it was ejb bean that can call any method on any SessionBean on server using reflection. It gets parameters for this method searches for method with given name that is the best for such parameter types. Java reflections doesn't provide way to find "the best" method simply, so I had to reimplement it by hand.

Matching method to parameters types is not straighforward (in some cases its ambigious which method should we run), so I've constructed algorithm for it and it was math, I'm sure, I can recognise it, when I see it.

Also, graph theory is often very useful, it gives you simple and effective way to think about complicated problems (may this be definition of math?).

So, I can't agree with you.

ajuc on April 1, 2009 7:08 AM

I'm new to programming and keep hearing that math is essential. It may be, but I haven't found any exotic forms of math required so far. Thank you for confirming my suspicions that being a math whiz isn't so necessary to being a good programmer.

Adam G. on April 1, 2009 7:08 AM

Someone needs to define what "good at" actually means. Most people use it in a relative/subjective sense, often comparing themselves against someone else.

Nick on April 1, 2009 7:08 AM

I use it sometimes for defining sophisticated logical expressions. In this level, mathematical logic really does the job.

zoltan on April 1, 2009 7:09 AM

I'm a CS major. More than half my classes are math. I hate math. Someone please help me.

Hoffmann on April 1, 2009 7:11 AM

I don't think the correlation Dijkstra was referring to between math and programming has anything to do with actually using math in your programs. Rather it's that the logical problem solving techniques and skills that a mathematician uses are the same as those that a programmer uses.

Carton on April 1, 2009 7:12 AM

I would like to mention that the quote says "mathematical inclination". This is not at all equal to knowledge of any particular mathematical concept, but more of a general assessment of what kind of competence one should be looking for. The common traits that are needed to be good in math and to be good at programming are very much the same: creative thinking, abstraction, logic, ...

While many particular mathematical subjects have their uses when programming (such trigonometry for graphics, calculus for simulations, graphs for networks or version control, and so on) that is another issue.

Previously you have stated that you are "not good at math", and backed that up with your SAT-scores. I would argue that this has nothing to do with whether or not you are mathematically inclined, just that the math one has to know for the SATs is not math that you are interested in learning. I guess that you would find the right kind of math for you both fun and easy, since you seem to be a good programmer.

MZL on April 1, 2009 7:15 AM

As a programmer considering himself as "not good at math" i proclaim that math can help in programming ;).

Ttheory of sets helped me to understand nested sets.

Joe Scylla on April 1, 2009 7:16 AM

Without math you will be doing only shitcoding (what 95% of programmers do for living - web development, enterprise development etc, other copypasting). Remaining 5% do some thinking, and this is where some math knowledge is helpful. The more the better!

Zlonax on April 1, 2009 7:16 AM

I felt a little bad after reading this because I think you have given a bad interpretation of what Dijkstra said in that extract.

I think that a mastery of one's native tongue is necessary for a programmer not because of the literary or grammatical value, but for the ability that gives to you. When I am programming I feel pretty much the same way as when I am writing something like a post in my blog or this commentary. I have to keep remembering and having in mind what I wrote and trying to make my point. Programming is kind of the same thing, we have our symbols, our sintaxis, but most important the logic that is within what we type. Dijkstra wasn't talking about languages, but the mastery of the language. I am mexican, and though my english is not near perfect, my mastery of spanish is quite good, and I have found that that has been useful for me.

And about math I feel the same way. I am pretty bad at math myself. But I've always been naturally "good" at programming. When I was in university I was always failing at my Calculus courses, but in the programming courses was quite the contrary. Which would give you the reason. But I think programming is very different from calculus, but is more like algebra and certainly even more like logic, and when I was in a course of IA and was studying formal logic, which nobody can't say it's not a part of math, I wasn't that bad.

Probably all programmers are different, and maybe when Dijkstra wrote that, programmers did have to have exceptional skills in math, because in those times things were pretty different, but I still think is not about math or languages he was refering, but to the abilities that share with the very complex art or science or whatever it is programming.

seigi ac on April 1, 2009 7:18 AM

Mathematics encompasses a wide range of knowledge, so it's almost certain that Dijkstra is correct. ;-)

The core of mathematics is the study of form, structure, pattern and relationships. Regardless of what branch you are in, this is the underlying foundation - Given these rules, what structures exist and can be proven, and what can be proven not to exist? And of course the meta-mathematics: How do these properties vary as the rules are changed?

It is no coincidence that Christopher Alexander was a mathematician before becoming an architect.

Even in the most applied numerical computational result-focussed areas, where the rules might be implicit and the behavior emergent, this is still the endeavor.

Cade Roux on April 1, 2009 7:19 AM

one word : Bayesian filtering for spam
http://www.paulgraham.com/spam.html

Paul Graham on April 1, 2009 7:20 AM

Discrete math was useful when learning programming and problem-solving skills. I rarely use any mathematics beyond simple algebra (eg, scale a number from one range to another range) and of course basic arithmetic (calculating address offsets, etc.).

Jeremy on April 1, 2009 7:21 AM

The problem is that you hear "math" and you think geometry, algebra, trigonometry, calculus, which is insanely narrow considering you quote a guy like Dijkstra. What he was most likely referring to was fields of mathematics that deal with sets, logic and recursion like finite math, discrete math, set theory, graph theory, combinatorics, etc.

Will you be a bad programmer if you don't know those things? Not necessarily. What Dijkstra meant was that there is a strong correlation between the aptitude required for being good at things like graph theory and the aptitude for writing good programs; namely, analytical problem-solving. The worst programmers I know attempt to solve problems by throwing things against a wall and seeing if they stick.

tb on April 1, 2009 7:22 AM

Well if you don't get algebra then you will never understand
int x = 4*y + 5;

I don't think most people have trouble with algebra...oh wait, yes they do. it was taught in high school. few understood it.

yes you can "program" with a cursory understanding of math but i've noticed a correlation between people who don't really understand math and the people who don't program well. they can have years and years of experience "writing code" but they can only understand programs at the most trivial levels. it's all voodoo to them.

Not that understanding math will make one a good programmer--you need to write lots and lots of programs for that and debug lots of other people's programs. But math gives your brain the tools it needs to be able to reason about programs, because programming is math. Recursion and iteration (sigma notation) come from math. proofs. Inductive proofs (so you don't have to write tests for every possible input value). and so on. it's all math.

if you can program then you are implicitly doing math. it helps (though you can get by without) to have a formal understanding of it.

that said, you don't need math to make websites.

dm on April 1, 2009 7:23 AM

Well there's some fields that you must be very good at numbers and conversion. Micro controllers programming is one those fields. It's not uncommon to code Asm alone in a single project. Hex to Bin to Dec fast mental conversions is A MUST. And you can't count on Standard templates library because it takes too much space (think about 2kB of RAM and 16 registers to work with). Most of the time you have to implement algorithms yourself, because there's close to zero chance of finding algorithm implemented for uC you're working on. Also there's a wonderful world of FPGA where you must have good logic algebra skills to reduce gates count and program C/Asm at the same time.

jpou on April 1, 2009 7:23 AM

I generally agree, but many have connected aptitude in music to math as well. If you know and appreciate music (not just the sound, but the structure), then math is easier for you. But that involves left and right brain as well.

I think the lynchpin with high school math that made me a better programmer was my natural love of (GASP AGAIN) WORD PROBLEMS! I loved word problems and always asked the teacher to assign us more of them (other students of course wanted to kill me).

But word problems are a quasi-real world application of the skills we were learning. It taught us application and problem solving rather than just here's the formula, solve it.

Kevin Kitchens on April 1, 2009 7:24 AM

Jeff, how were your math marks? =)

Brian L on April 1, 2009 7:24 AM

I think you missed the point, he said "mathematical inclination" not being "good at math". Being "good at math" usually means you can compute a lot of things. Being "mathematical inclined" usually means you enjoy working with abstractions. A lot of "mathematical inclined" people are not "good at math". The point is a propgrammer's job is to work with abstractions and make them work reliably. Heck, I even heard of a programmer, who took the real real world idea of asteroids colliding, and created an original abstraction of their movement behavoir. Sure sounds like a "mathematical inclination" to me.

Chuck on April 1, 2009 7:28 AM

I think the best argument is this quote by Gian-Carlo Rota:
"Most people, even some scientists, think that mathematics applies because you learn Theorem Three and Theorem Three somehow explains the laws of nature. This does not happen even in science fiction novels; it is pure fantasy. The results of mathematics are seldom directly applied; it is the definitions that are really useful. Once you learn the concept of a differential equation, you see differential equations all over, no matter what you do. This you cannot see unless you take a course in abstract differential equations. What applies is the cultural background you get from a course in differential equation, not the specific theorems. If you want to learn French, you have to live the life of France, not just memorize thousands of words. If you want to apply differential equations, you have to live the life of differential equations. When you live this life, you can go back to molecular biology with a new set of eyes that will see things you could not otherwise see."

emeritusl on April 1, 2009 7:31 AM

mathematics <> arithmetic

Cade Roux on April 1, 2009 7:31 AM

Hey Jeff, you're looking at all the wrong math. Math is much too large of a subject to just claim "it doesn't help." Calculus doesn't help.

Discrete math http://en.wikipedia.org/wiki/Discrete_mathematics (logic, sets, number theory...) help programmers immensely. Good programmers will be good at this kind of math.

Jim L on April 1, 2009 7:32 AM

Don't confuse math with arithmetic (or calculus, or anything applied or specific). Math is all about abstract reasoning. As Bertrand Russell said:

"Mathematics may be defined as the subject in which we never know what we are talking about, but we know whether what are saying is true."

In math, objects are defined based upon their properties, as opposed to specific, concrete things. It's the abstract reasoning that's useful to a programmer. Any time you're dealing with interfaces or abstract classes (or whatever your language calls those concepts) you're applying abstract reasoning. I think that any programmer who can't reason well abstractly may be able to pound out cookie cutter code, but probably won't be able to understand things like design patterns, or when its ok to break those rules.

I perceive programming to be very similar to writing a proof. I have a math, rather than a CS background, which may explain my bias. Most CS papers that I've seen look like math to me. Design patterns, class hierarchies, etc, all look like math to me.

Matt on April 1, 2009 7:33 AM

when doing a bachelors degree in statistics, i found it easier to remember complex formulea, theories and curves by implementing them in C. Jeff, for some obscure reason, i found it twice as hard to write statistical applications in basic!!
an example of a program i wrote in my first year was simple ANOVA or analysis of variance. of course, once the program is written, the fun wears off and the method is sort of yours for life.
i agree that programming helps one learn math and maths "sharpens ones saw" very nicely. i never did get round to writing a program to "calculate allocation of resources optimally within given constraints" and every now and then, i wish i had one :-)

jake on April 1, 2009 7:34 AM

Im often ashamed that ive got nil math skills, but i find math so boring i just cant bother to learn it. I was taking a statistics and probability course that would directly help me at a project but i got out of it. I cant do the exercises, get some time to stop and learn it. Its anoying to manually solve this stuff. Maybe im spoiled because when programming i can just write the formulas and the computer solves it for me.
But to really learn math, i need to sit down and do loads of exercises til its stuck in my head. Those huge frequency tables, enoumous equations... all those aparatus, just plain anoying to do it mannualy. But, unfortunatly, its what it takes to learn it. Theres no other way. Its the same as in programming: to be a better programmer you need to program a lot.

But im still willing to learn math. Any recommendations(books, methods, etc)?

paulo on April 1, 2009 7:34 AM

LTMSQ, this is an outstanding april fools, logic and reason are also just "nice to haves" when it comes to programming.

Derek on April 1, 2009 7:34 AM

Im often ashamed that ive got nil math skills, but i find math so boring i just cant bother to learn it. I was taking a statistics and probability course that would directly help me at a project but i got out of it. I cant do the exercises, get some time to stop and learn it. Its anoying to manually solve this stuff. Maybe im spoiled because when programming i can just write the formulas and the computer solves it for me.
But to really learn math, i need to sit down and do loads of exercises til its stuck in my head. Those huge frequency tables, enoumous equations... all those aparatus, just plain anoying to do it mannualy. But, unfortunatly, its what it takes to learn it. Theres no other way. Its the same as in programming: to be a better programmer you need to program a lot.

But im still willing to learn math. Any recommendations(books, methods, etc)?

paulo on April 1, 2009 7:34 AM

this really depends on what you are writing. some fields, like graphics, audio, games... in fact anything multimedia or attempting to model the real world is a complete minefield of advanced maths. :)

jheriko on April 1, 2009 7:36 AM

Raytracers and 3D physics simulations as a hobby in college required matrix algebra before I ever took the course.

but I was most impressed by a fellow student who wrote a program that could solve/reduce equations symbolically... basically shuffling text patterns in a tree structure...

but it could handle most of our homework for math 'proofs'!

Eric on April 1, 2009 7:37 AM

I haven't read most of the comments above me, but I imagine most of them endorse math knowledge for algorithms and other small-scale situations. In addition to these, math can help you derive good abstractions! Admittedly, the kinds of abstractions that are easiest to derive with math are not always the kinds of abstractions that most procedural or object-oriented languages are well-suited to, but in out multicore future when functional programming possibly begins to gain real mainstream traction, these abstractions will be trivial to translate into code. Algebraic structures, category theory, type theory, discrete maths, graph theory, and more. All can be invaluable.

Jake McArthur on April 1, 2009 7:38 AM

I was a math major, one of my last classes was on multidimensional partial differential equations. Oh, the good old days.

Skip forward a few decades. I'm working as a NOAA contractor, but on the display side instead of the modeling side. Another group has a supercomputer that runs weather models -- multidimensional partial differential equations.

Right after I leave that job I'm taking a graduate level course on parallel programming... and we have access to that supercomputer! The instructor chose to focus on a particular type of parallizable problem -- multidimensional partial differential equations. He never really teaches the class the math -- it's a multiyear sequence from calculus for most people -- but he goes over the algorithms without deep explanation. It takes me a month to realize it, but I suddenly make the connection to the long forgotten class and everything snaps into place... and I'm the only person in the class (other than the professor) who has any idea what's going on. :-)

This is an unusual case, and of course scientific programming (even if just on the display side) is probably going to attract a disproportionate number of people with strong math backgrounds, but it's definitely a case where knowing math made the difference between blindly stabbing at code and understanding the problem well enough to make meaningful contributions.

(Earlier, while at NOAA? I did do some overt scientific programming where I needed my math/physics skills in addition to my CS skills, but obviously that's domain knowledge that will naturally select people with those math skills.)

Chris on April 1, 2009 7:40 AM

I feel my relatively basic math skills are my biggest weakness as a developer. I personally am humbled by the mathematician I work with on a daily basis.

Christopher Baus on April 1, 2009 7:42 AM

Knowing math is a must for competing in the Google Code Jam. http://code.google.com/codejam/ I did horribly (only survived one round) but it was insanely fun. If someone likes math and programming I highly recommend trying it out this year (will probably be July again).

Joel Clermont on April 1, 2009 7:45 AM

One thing that translates pretty directly is a sort of code algebra. The most simple speedup you can think of, pre-computing something outside of a loop, is very similar to distributativity. Code that commutes is threadable..

Justin on April 1, 2009 7:46 AM

I have used "higher" math knowledge in a following way. We had an applications where users could set the time they wanted "the event" to happen with 15 minutes granularity with a 5 minute interval. With a large number of users this meant that we had huge peaks at these times and the application went slow as hell. We used normal distribution to distribute the start times around the specified time and got really great results.
Other maths i have used can generally be considered common sense i think.
But of course everything depends on the domain. A friend of mine writes software that implements formal methods. Maths, especially logics, is kind of important there.

Heiti Allak on April 1, 2009 7:47 AM

How about discrete probability distributions generated from log files to drive a simulation of web load on a website (prior to the days of products that can do that for you) ?

Or something much more basic, like calculating the number of seconds to sleep until the beginning of your next timeslot given an interval length and an offset... not rocket science, but tricky enough... (hint, it matters where you do modulus in your equations)

Eric on April 1, 2009 7:47 AM

I have made a Venn diagram to illustrate my argument:

http://www.flickr.com/photos/neallindsay/3403808093/sizes/o/

Neal Lindsay on April 1, 2009 7:48 AM

Actually, I think Jeff is slightly wrong. Because there may be more than one way to get the right result(s), but there's only one right result. So programming is part maths (I have something, and I need to get something else), but part art (oooh, isn't that lovely looking code, easy to read!)

Brendan Donegan on April 1, 2009 7:48 AM

I would imagine that with "an exceptionally good mastery of one's native tongue" Edsger Dijkstra meant that when you've got a good understanding of your native language, you can analyze a problem description in a analytical way. Being able to understand all the words and the correct grammatical meaning will help you solve problems easily.

Another reason why Edsger never published in Dutch is because at the time (and if I'm correct neither now) there where no Dutch Scientific journals in the field of computer sience. He did however wrote manuscripts in both dutch and english (dutch example: http://www.cs.utexas.edu/users/EWD/ewd00xx/EWD41.PDF). But in the Netherlands it's pretty normal to publish articles in the English language.

Davy Landman on April 1, 2009 7:49 AM

Sometimes math sculpts your point of view, however...
consider attempting to alert for notable downspikes in a performance metric (like loss in hits-per-second on a search engine)...

The average minus some multiple of standard deviation results in too many false alarms, but a visual approach led to a 'seemingly' more robust algorithm that we then translated into equations for downspike detection.

Maybe there are more sophisticated models in statistics for that...
but not being strong in stats keeps me unaware of what they may be.

Eric on April 1, 2009 7:52 AM

Actually, I think a certain inclination helps. But it's not related to encyclopedic knowledge of math, but rather on the way one thinks about a problem.

Going back to the original question, I once had to optimize a graph editor, and had to come up with a way to check if the mouse was on top of a bezier curve very fast, and knowing a bit of math was quite helpful.

Here's an the old blog post (I don't maintain that blog anymore) with the code and an explanation:
http://codeknot.blogspot.com/2005_07_01_archive.html

JC on April 1, 2009 7:52 AM

Don't forget that at the time (the early 70's) Dijkstra (and many others e.g. Niklaus Wirth) were into formal methods: mathematically-based techniques for proving the correctness of a program.

In the early 80's I once - having forgotten his bent - attended an open lecture given by Wirth on 'improving the correctness of a program'.

He (or, more accurately, his mathematical proofs - which spanned many an overhead slide) lost me at about minute ten, which was about five minutes longer than he took to lose the mainly-COBOL audience ... 8-)

rowan on April 1, 2009 7:53 AM

I wrote a script in an ECAD environment to draw boxes around certain components. The components could be rotated to any angle though, so the boxes had to be rotated as well. Using a rotation matrix (and a reflection matrix for parts on the other side of the board) made this almost infinitely easier to do than trying to do it by hand.

Ryan Fox on April 1, 2009 7:55 AM

Bits of math that are extremely useful in my programming career:

DeMorgans laws (basically, simplification of boolean statements)
Set Theory (very useful when doing your if-this-then-that type statements, to make sure you've covered all your possibilities)
Base x Number Comprehension (there's probably a better name for it, but I refer to an understanding of what a binary, trinary, etc. number is, which can be helpful understanding WTF is going on when dealing with hex/binary/base10/octal type stuff)
Trigonometry (Handy whenever you're computing things with positions, vectors, "bounces", etc. I've seen a lot of people vastly overcomplicate calculations to figure out angles when they could have plugged in the sine or something. Its funnier when they resist correction, because "sine's too hard.")

Guillermo Llosa on April 1, 2009 8:02 AM

Well, I think, math is an important tool to find algorithms for a sufficiently complicated problem. If you program in the right corner of problems, you will need math, because those problems occur. If you program in the wrong corner of problems, you will never see math.

I for myself have had several problems that required heavy math knowledge. Compilers (transformations, language models, parsers), a navigation system for a diving robot (matrices, quaternions, filters, filter construction), message compressions for a DSL for distributed systems (thompson construction, graph theory), motion planning for a robot (matrices, DH-parameters).

Of course, if all you have is the buisness requirement of price = (buying cost + personal cost) * 1.2 (or similar things, of course), you won't need the tool math. You will just need your regular programming boots and walk right through it. However, once the requirement is: Given these accelerations and rotations, give me a vector where to go, you will need the math-machete and your sturdy programming boots in order to get anywhere. As iirc you once said, use the right tool for the job.

Greetings, Tetha

Tetha on April 1, 2009 8:09 AM

I think it's more how one goes about approaching a maths problem, or proof, or whatever. In my brief stint teaching C++ to high schoolers, the problem I had was getting them to think analytically and do problem-solving, not syntax or logic errors

Reading and understanding an electronic schematic can also be linked to programming ability i.e. understanding inputs and outputs, current flow, etc.

Nchantim on April 1, 2009 8:10 AM

First off, I've been enjoying your blog for quite some time and this is my first post. Thanks for the excellent material and inspiration!

I'm currently working to learn Direct3D in an attempt to get into game development and, as you mentioned, those writing 3D games definitely need a good knowledge of math. I, unfortunately, am not so great at it. I learned enough to get through it as needed up til Calculus 2, but found I rarely use it in my daily job (except perhaps on the few financial components of my company's web application).

Now that I'm learning how to use math for 3D games, it's amazing to see how it can be used to model real-world objects on a computer. I still don't need Calculus yet, but principles from Geometry and Physics are useful for what I'm doing. I would agree that you do not need to be mathematically inclined or enjoy math to be a great software developer. It does help if the libraries available to you do not fully accomplish what you need. But if you have a fully-capable library available to you, why reinvent the wheel?

Jeromie on April 1, 2009 8:10 AM

> What code have you personally written where a detailed knowledge of math made your work easier?

Paging routines in the times before scrollbars and baked-in controls mercifully made such routines moot.

I saw, and fixed, more bugs where it was apparent that the original coder didn't understand modular arithmetic. I can here the inner dialog now: "Oh, no, that's not right. Let me stick a +1 here and see if that fixes it... Nope, maybe it should have been a -1... Nope, ok, then let's poke at it here, and there, and there... It's so close that I can't waste the time to actually FIGURE OUT WHAT THE H--- I'M DOING..."

Trivially simple, but so often done so terribly wrong. I still have to fix some of these disasters to this day. A (very) little bit of math is all that it takes.

Pager on April 1, 2009 8:12 AM

It is pretty dangerous to just say "math".

As a "math" major, there was some "math" that I detested, and some that I loved. There is no one "math".

If you said "group theory", or "string theory", or "complex analysis", or "numerical analysis" (one of my favorites) then you could start this bit.

You probably mean "algebra", and while necessary, is quite boring!

Steve on April 1, 2009 8:13 AM

For me my maths degree has never been directly useful in my programming but still I consider it to be an enormous help towards my being a competent programmer. Why? Simply because it taught me how to break big complicated problems down to small solvable ones and to see patterns to aid this.

Gaz on April 1, 2009 8:14 AM

Computers actually helped me to learn advanced mathematics.

Prior to developing an interest in programming I was a dismal mathematician. Primarily because I didn't see a need for anything beyond arithmetic in everyday life.

Programming changed all of that.

Of course, I learned how to program almost 3 decades ago so you might say that Edsger Dijkstra was right about me and what I needed to do for that time.

Mac on April 1, 2009 8:14 AM

Working through the Project Euler http://projecteuler.net/ problems can help immensely.
I'm a "business applications" type programmer, so anything graphics/matrix/3D makes my head hurt. That being said, when working with financial apps, it can be surprisingly difficult just to get things to add up.

J on April 1, 2009 8:14 AM

In the early part of my career I did a lot of work on systems to animate and visualize complex data sets in 3D. Because the system was ported to many platforms, some of which did not have native 3D graphics libraries available, I had to write my own portable layer. So I used a lot of trig and matrix math.

The latter part of my career has been in finance and sometimes I work on risk modeling which brings in a lot of statistics, cash flow analysis, and monte carlo simulations.

But even for simpler applications, like a trade entry system that does automatic allocations, there can be some interesting math problems so I would agree with the general premise that being good at math is helpful in a programming career (but not mandatory).

David Avraamides on April 1, 2009 8:15 AM

Never having been on the web side of programming (which may be where much of the divide is), I'm up to my eyeballs in math every day (and have for my entire career). In the last three months, I have used calculus, graph theory, group theory, abstract algebra, sampling theory, linear algebra, error analysis, statistics, and I suspect I'm going to be having to use topology to solve the problems on my desk today.

I don't want to claim that I am the usual case, although my career has been a varied one, but the advantage with at least being familiar with the topics of Mathematics up through the usual undergraduate studies (basically all of the above plus ODEs and PDEs), is that you know what the tools are.

I'm a strong believer in your comments that good developers need to be capable of JIT learning, the problem comes when many could-be-good developers don't even realize these things exist to be learned, and end up going the wrong way.

If I were to pick two tendencies that would raise my opinion of a developer in an interview, they are a comfort with mathematics (as it really is, and not what they teach in lower education) and the Maker spirit.

Jeffrey McBeth on April 1, 2009 8:17 AM

You sir, have created a false argument. Should all exercisers be able to swim? If you have a team competing at a relay tri-althon it doesn't matter if the runner can't swim.

'Programming' spans too many things. If you are building the network stack for a portable device, I certainly hope you're mathematically inclined. Otherwise it will probably have subtle bugs. If you are writing a game on that device, it almost certainly more useful to be good at knowing what is fun than to be mathematically inclined.

Steve Steiner on April 1, 2009 8:21 AM

I was going to point the same about the Indiana Pi Bill (http://en.wikipedia.org/wiki/Indiana_Pi_Bill). But another important remark is about the multiple disciplines that "software development" represent. The amount of mathematics that a game developer needs is significativity different that the one needed by an average web developer.

Angel on April 1, 2009 8:24 AM

Jeff, you have always said how important comments were to your blog, and sometimes you even address them in follow-up posts... do you take requests? I am requesting a follow-up post based on the comments in this thread. These posters in particular have something important to say (I may have missed some, and they're probably be more by the time I post, but the common theme should be clear):

David A. Lessnau
Ryan Smith
Eric
Delmania
tberthoff
Henrik Warne
David Dollar
Carton
Cade Roux
tb
Chuck

I'll try and add in my own contribution: when mathematicians say "Math", they are not talking about computation, or a particular tool (calc, trig, etc.), they are talking creatively pulling together a bunch of ideas in a rigorous manner such that a new idea is created. This is "proof", the heart of math, and it's only complete if it's communicated clearly enough that others can assimilate the new idea.

Wouldn't it be amazing if every programmer was trying to rigorously pull together existing ideas into new ones (even if they are just new to the programmer), and then making it a criteria for success that others (specifically the compiler and the coworkers) could assimilate/understand the idea?

Jeff, I was hoping you could help, even just a little, squash this idea that math doesn't have enough "real world" applications. I can't think of any other fields that can make someone more powerful (from an education perspective), in more fields.

Final note: I've been reading your blog a long time, and I'm ready to declare, no matter what you grades were in "Math" at school, no matter how crap you are at arithmetic (I'm trash at it myself...), you, sir, are a fantastic mathematician. Try to be proud of that.

MathIsBeautiful on April 1, 2009 8:24 AM

Q>What code have you personally written where a detailed knowledge of math made your work easier?

Understanding vector space transformations to implement a software vertex transform fallback. Sadly enough, in 15 years of math-related school, I only had about 3 months of vector space math, only a couple of lessons covered the issue (say 8 hours) and quickly dismissed it as trivial.
I have to thank NV_vertex_program extension specification, which allowed me to finally do the jump.

I'm still looking for someone able to explain why v0 dot v1 is cos(angle(v0, v1)) (assuming unit length vectors). For all the rest, the GL spec covers all the math needed: operator+, operator*, RCP and little more than that. Oh yeah, sometimes I use operator% as well!

What Dijkstra said in 197x was probably true at that time - if you get an handle on a 30 years old book, you'll notice that they are way more straight, direct and realistic on **getting the things done for real**!

MaxDZ8 on April 1, 2009 8:25 AM

Knowing how to do dot-products is useful when doing game programming :)

lukehashj on April 1, 2009 8:26 AM

The primary skill of a programmer is to study and understand problem domains that they have little or no prior experience with and then apply logic to make the problem deterministic.

Having more knowledge than is necessary has never hurt anyone but a decent understanding of algebra is sufficient for most situations.

If you are building a video game, you will need a decent understanding of geometry and linear algebra.

If you're doing something more math oriented than that, go to your local used bookstore, buy a college textbook and crack it.

Timothy Lee Russell on April 1, 2009 8:27 AM

Yes, I'd argue you need math skills. Not specific skills, but the general reasoning progress. How else are you going to reason about correctness, runtime/memory requirements, etc?

Or maybe we should just call them logic skills, instead. You're exercising the left side of the brain. (Yes, you should be right-brained, too. It's no accident that many good programmers are musicians or other artists)

I prefer to think of good programmers as modern "Renaissance Men" (and women, of course!). You need to know a little bit of everything, and you should be able to quickly dive into a new subject

Rachel Blum on April 1, 2009 8:35 AM

I will use EWD's words..
.....The pragmatic engineer believes in the correctness of his design until it has failed to work properly; the scientific designer believes in the correctness of his design because he has understood why it must work properly. ....

source: http://www.cs.utexas.edu/users/EWD/transcriptions/EWD06xx/EWD690.html

aita on April 1, 2009 8:37 AM

I have to agree with a bunch of people who posted before me: you don't have to know how to solve specific types of mathematical problems to be a good programmer. But the mind-set that you use to solve math problems is very similar to the mind-set that is required to write a program. To me both basically consist of breaking a big complicated problem down into a collection of simple steps. Once you learn basics (arithmetic, loops, etc.) you can build on that. Really, even advanced calculus is nothing more than new ways to apply lots of little arithmetic steps to a problem. If you can break problems down and remember the steps that you used to solve a problem then you can do math or program.

To answer Jeff's question, here are some actual mathematical things I've needed in my current job:
1) Trigonometry - figuring out the angles for 3d displays of pipes and conveyors
2) Linear algebra - more 3d displays and vector-based movement of objects
3) Graph theory - path-finding
4) Statistics - tracking staytime, utilization etc. of objects in a system

I'm sure there's more (including a lot of very basic stuff that I don't even realize that I'm doing), but that's what's coming to mind right now.

A.J. on April 1, 2009 8:38 AM

Worked on missile defense trajectory and tracking software. Obviously tons of math and algorithms there, and pretty fun to boot.

drewh on April 1, 2009 8:45 AM

From Douglas Adams:

"It is known that are an infinite number of worlds, simply because there are an infinite amount of space for them to be in. However not every one of them is inhabited. Any finite number divided by infinity is as near nothing as makes no odds, so the average population of all the planets in the universe can be said to be zero. From this it follows that the population of the whole universe is also zero, and that any people you may meet from time to time are merely products of a deranged imagination."

Charles on April 1, 2009 8:46 AM

Oh boy. Wait until Forbesey gets a load of this.

David Dawkins on April 1, 2009 8:49 AM

Please tell me this post was an April Fools joke?

Joe on April 1, 2009 8:55 AM

Learning algebra was remarkably like programming. You have steps you can take, and some steps get you closer to the answer, and other steps don't, and you've got to lay out the sequence of steps to get from what you're given to what you're asked for.

The same way you write a function where you're given inputs and you have to lay out the steps to produce an output. Instead of following those steps yourself, you write them into code.

Not to mention that there are countless times that I have to "solve for x" in some simple equation so that I can write the variable assignment "x = (some function of a few other variables)" If you can't put the x all by itself on the left side of that equals sign, you're kind of stuck there.

Now there was the time I was asked to calculate the orbit of a satellite from two points along the orbit and the times they were at those points. I tried cobbling together the calculus I learned in college to come up with a simple formula, failed, and then remembered Kepler's law... a line from the center of mass to a satellite sweeps out area at a constant rate. So I'd guess the shape of the ellipse, find the proportion of the area swept out between the two intercepts to the area of the whole ellipse, and figure out which way I needed to move one of the foci (the other being the Earth, of course!). Rinse and repeat until I got "close enough".

That problem could have easily appeared on a test in one of my math classes... well, actually not, since that iterative solution is damn slow to work out with pencil and paper. So programming is math as done by one of those mathematical savants that can instantly do insane arithmetic in their heads.

Ken on April 1, 2009 9:00 AM

Reed Solomon error correction code parity and syndrome generation for embedded systems. The theory is incredibly interesting (finite Fields, Binary Galois fields, etc). The math itself is just XOR ops.

Daniel on April 1, 2009 9:01 AM

Good question. I work in finance, and I've yet to find a quant that can program well!

Paul on April 1, 2009 9:02 AM

Funny, just yesterday I stumbled across Pascal's Triangle when working on our reporting tools. You see, we can drill down on an arbitrary number of fields, and to keep things fast we cache the drill-downs. But how do you generate them in the first place? You could generate each one from the full report, which would be incredibly slow with large data sets. Or you could consecutively drill down until you get the desired report, caching along the way. This is also slow and problematic.

So what I needed to do was to figure out at what point it becomes too expensive to search our drill-down cache (a hash table). Which leads me to Pascal's Triangle, most commonly known for its application in binomials. But it is actually a count of all subsets for a set of a particular size.

You can't be good at optimization without being able to do Big-O analysis. Which involves combinatorics. In general, you can't be a great programmer without a good understanding of set theory, graph theory and combinatorics-- since they come up all the time in algorithms and network administration.

Sure, 99% of programming is pretty simple stuff. The world's greatest car mechanic isn't going to give you a better oil change than an average apprentice-- unless he discovers something wrong with your car.

Mediocre programmers can muddle through their careers writing mediocre software, never knowing why they might even have a need for mathematics. Their code will run slowly, even on fast machines, and they'll never know why.

Dijkstra's algorithms, by the way, are taught in combinatorics classes. He's best known for his graph traversal algorithms, which are mathematics even though they don't involve the manipulation of numbers.

David Leppik on April 1, 2009 9:02 AM

These attempts to minimize the importance of C programming and math are futile. Real Programmers(TM) simply do not make such arguments. It's not so much a matter of being right or wrong. It's more a matter of knowing when to hold 'em and when to fold 'em.

By the way, your constant assertions that knowing C is not necessary inspired me to actually bear down and start the process of learning C. I can tell you, you don't know what you don't know about computer programming until you actually learn C. My suggestion: actually learn C and get back to us.

On math and computers, one only need look up the definition of the word "compute" to see what any Real Programmer(TM) would say on this topic.

Michael on April 1, 2009 9:06 AM

Anyone who can write a loop and know that it works before it is run has just done a (usually simple, but not always) inductive proof. Similarly, following control flow and keeping track of what you (the programmer/the program) knows at any given point requires very nice logical skills.

But then too the "left brain" vs "right brain" thing is all nonsense. Perhaps (the research wasn't all that convincing) peoples brains to tend to think in "logical" lines on the one hand, and in "holistic" lines on the other, but this dichotomy is used far too often as a half-assed excuse to justify a persons unwillingness to learn something difficult or different. "I can't learn math - I'm an artistic person." Yech.

Good programmers must have both sides - the ability to think logically in the small (following specific chunks of code), but also the ability to see a wider viewpoint on the problem (how do these pieces fit together).

glt on April 1, 2009 9:11 AM

Localizing the number 3 is not a matter of mathematics - it's an issue of character sets.

The argument "The ability to write clear and concise code is a one-to-one function with the ability to construct elegant proofs." is an old saw by people who see math as the center of the universe. I would argue that most day-to-day coding doesn't require much beyond simple maths and maybe the occasional foray into algebra.

AceF on April 1, 2009 9:11 AM

What about algorithmic growth analysis? That's a fundamentally mathematical skill that is arguably at the heart of quality software development. Ceterus parabus, you're probably not going to get much work if all of your stuff runs in O(n^3) when it could be running in O(n log n).

Bill on April 1, 2009 9:13 AM

Once a while, I had to code a quite complicated decision algorithms, that came as a spec with many input variables and numerous dependencies between them.

I translated the problem input to predicates, wrote the required truth tables, reduced them with external impossible known cases, simplified them with Boolean algebra and came up with several short equations.

Spec translation and equations took almost 2 full days but implementation was less than 1 hour. QA did not report significant bug so far, but maybe I'm just lucky :-)

Two things come to my mind :

- More than half of my co-workers did not understand the math that I used.

- I don't think I could have done it without proper math knowledge (even if this knowledge may not seem complicated).

drb on April 1, 2009 9:16 AM

Set theory is what relational theory is based on. Therefore, knowing set theory can make your relational queries (read: SQL queries, although SQL isn't 100% relational) that much better.

Chris on April 1, 2009 9:24 AM

I would argue that the *logically* inclined make the best programmers.

I can see the corollary people are trying to make, math *is* logically driven, but one thing does not equal the other. A math whiz does not necessarily a good programmer make.

Nico on April 1, 2009 9:25 AM

I think the strong math guys (mathies?) are important, they write the code that powers tools, compilers, frameworks, search engines that the strong app design guys (appies?) use to design and build end user applications that real people use to get work done.

Without the mathies we couldn't build great apps but without the appies no end user would ever use something written by a mathie. Appies and Mathies need each other to get usable software to users.

Keith on April 1, 2009 9:26 AM

I'll pile on to other comments...

It seems the point is being missed. Math facilitates being a good programmer not because one needs to "do math", but rather because being "good at math" or developing one's math skill, develops the *thinking processes* that are key to being an effective developer.

Thinking like a mathematician helps a developer to be crisp in thinking about their work. Pick up any good Discrete Math text to see how thinking like a mathematician maps to effective programming approaches.

There are probably other disciplines that develop the same clarity of thought, but perhaps not as effectively as math.

Mark Kohalmy on April 1, 2009 9:27 AM

Several people here have observed that, for specific problem domains, certain areas of applied mathematics can be brought to bear. True enough, but plenty of software doesn't need that kind of stuff.

Jeff's post made me think of pure mathematics. I wonder if there's something about the idea of mathematical proof that makes good programmers...? Proof is about asserting some facts and then deriving interesting results, and that can be a pretty good approach to coding. After coding some complex algorithm, maybe involving concurrency, the thought "I know it works in all cases because..." is strikingly similar to "I know this proof holds because..."

Pure mathematicians are well-known for losing interest at the point where they fully understand the problem, and leave the boring part of creating a solution to engineers, etc. Plenty of people approach software in the same way :-)

Martin on April 1, 2009 9:32 AM

There's plenty of math that's useful or even necessary. The problem is that we think of it as computer science rather than math. Like others have said - probability, set theory, number theory, graph theory, formal languages, automata theory, logic, etc. (and of course the basics like arithmetic and elementary algebra and coordinate geometry).

And other branches of mathematics are less useful, unless you're specifically dealing with them: calculus, real and complex analysis, abstract algebra, non-Euclidean geometry, etc.

But this just goes to show you that to even ask the question is kind of silly. To try to divide math into "CS math" and "non-CS math" is kind of pointless.

Jon on April 1, 2009 9:34 AM

"Hash a set of 4-character codes made up of uppercase letters". Familiarity with math lets you look at it from a different angle and arrive at the solution.

Also, the army had a 37-character alphabet for flash messages, and needed a binary-transfer protocol; I did is as a 8->5 uuencode rather than a typical 8->6 bit conversion, but I think math played a part.

The act of symplifying boolean requires Euclidian logic; exploiting "knees" in result graphs is a calculus trick; these are part of a modern math syllabus without which, a software engineer is only half-effective in code reviews and tightening.

Allan Clark on April 1, 2009 9:36 AM

I ordered this book about Art and programming, and wound up needing to get a minor in mathematics to understand it. It really helped my coding, though.

Pat Morrison on April 1, 2009 9:40 AM

Another Dijkstra quote (from http://www.cs.utexas.edu/users/EWD/ewd08xx/EWD829.PDF, in Dutch, but I'll translate):

Considering the pleas for the needs of "the casual user" and the intellectual limitations of "the average programmer", one must always maintain a clear distinction between the problems intrinsic to computing science and, on the other hand, the difficulties caused by the failure of the American education system. To expect from university graduates an effortless mastery and effective use of their mother tongue is something that, over here, we no longer fully take for granted, but in the United States would be absurd and unreal.
It explains the American emphasis on "readability", "self-documentation", and similar, unspecified virtues.

(Yes, he really writes like that. Unsurprisingly, his English was much simpler.)

rp on April 1, 2009 10:02 AM

The extent of my use of math in programming was to model a horizontally oriented chemical tank and to calculate capacities and liquid levels in the tank. The tanks were cylindrical and had rounded end caps. Not exactly a fun equation to code and I had to make several passes at it to get it just right but not near as complicated as compression or encryption algorithms.

Bryan Richardson on April 1, 2009 10:07 AM

I think you are confusing "mathematically inclined" with "good at math"

It is about a certain way of thinking, about enjoying certain type of brain activity (disciplined, rigorous, algorithmic, creative at times).
For various reasons (ie. a bad teacher that turned you off), you might never get to be "good at math" but you are still "mathematically inclined".

Mihai on April 1, 2009 10:15 AM

I'm currently reading 'sync' by Steven Strogatz, who is professor of applied mathematics at Cornell University.

It describes how mathematicians have approached the problems of predicting large populations of coupled oscillatory systems.

The process is partly trial and error, but mainly a question of coming up with representations of the domain using techniques which make the problem tractable or amenable to computation.

Although the language of the representation - calculus, non-linear dynamics, fluid flow equations - is not programming, the process of selecting from a palette of techniques and mapping the domain to a representation coloured with that palette is what makes a mathematician.

The processes used - constructing models in a formalised language, taking into account any restrictions on the capabilities of that language, and shifting representation to work around them - is much the same as the process of creating software.

Some software may borrow some techniques from maths, but knowing the techniques means you have a mathematical training, not a mathematical inclination.

A mathematical inclination is a mindset which is used to transforming a real-world problem into a elegant, tractable, useful, formal model.

Pete Kirkham on April 1, 2009 10:18 AM

You have a very simplistic view of mathematics, computer science, and programming. You keep quoting people like Dijkstra and fawn over Turing award winners but you have not spent much time with actual computer science to understand what is going on.

The idea that you "just in time" learn math when you need to balance a checkbook or need DeMorgen's Law is patently ridiculous. If you want to be some code monkey or whip on one-off websites, you probably don't need to be great programmer, computer scientist, or mathematician. You're going to have a hard time doing anything non-trivial in programming without the knowledge of formal theory and the ability to understand the Caluclus, Linear Algebra, Graph Theory, and so forth.

You don't just "go learn Graph Theory now" right when you need to write that cycle detection function for your file system checker. That's ridiculous. If you are pumping out JQuery monkey code then maybe not. But you're talking about "good" or "competent" programmers.

Honestly, why do you keep calling yourself intellectually curious? You keep railing against understanding how computers actually work and have constantly poo poo'ed on mathematics. Look at Steve Yegge's stupid list?

1. You've got to be kidding? In what way is learning Math a "snap" for good programmers and the concept "good programmers know math" is wrong?

2. Really? How do "THEY" teach math "WAY" wrong? This is a common objection. To wit, mathematics education can be improved, but so can everything else. I still find many, many people with a stellar grasp of mathematics. How is math taught wrong exactly? Please don't cite old papers and people trying to promote "New Math" that failed miserably. Also, what is the "right way to teach yourself math?" Are you kidding? You can't just make naked assertions like that and say "well, see, you don't need math anyway." This whole post is some of the most illogical stuff I have seen in a while, and I deal with freshmen.

3. You don't just pick up a little math whenever you have a little free time. This person must have never studied mathematics. It's not like, "Oh, I don't trigonometry but I think I will work on some integrals today, shouldn't take me until lunch time to do it. No sweat."

4. You're getting ridiculous. No one is saying that to be a good programmer you need to be one of the 20 people who fully understand Andrew Wiles' famous proof or keep up monthly with the AMS. That's just a stupid strawman. The idea is to have a solid fundamental understanding of mathematics. This is just a distraction more than anything else.

5. Bah. Whatever.


You keep talking about this business of "good programmers will have the intellectual curiousity ..." whatever that means. However, this post and a substantial amount of your posts just smack of anti-intellectualism, certainly a lack of intellectual curiousity. Your curiousity seems to extend as far as having a very vague and confused Wikipedia view of what some of the big terms mean, nothing of any subtance.

Charles on April 1, 2009 10:33 AM

I think programmers need to at least comprehend *basic algebra*. I had a coworker who had trouble writing code for a scroll bar+scroll pane in Flash because he couldn't wrap his head around a/b = x/c, solve for x. I finally had to write out the formula for him in Actionscript because when I had it in algebraic notation he was still having trouble.

He's not a very good programmer.

I agree with all the people who say it's the thinking and attitude of a mathematical inclination, rather than the specific math skills, that are important for programming.

Dodeca on April 1, 2009 10:35 AM

Back in my day, people believed math skills were required for any kind of scientific pursuit, biology, chemistry, computers. It is probably true, but it discourages those kids who may not excel at computational math (doing math in their head), but can understand higher math concepts given the crutch of a calculator.

I remember my mom telling me I couldn't be a scientist since I wasn't good at math.

There are lots of different types of programmers needed in this world. We need far more than we can currently supply with our educational program. To fill this need, we need to open up the field even to people who failed calculus. There are some types of coding you can do without knowing higher math. Basically, math skills shouldn't be a requirement - it discourages far too many young people from pursuing computer science and/or software engineering. You probably do need math for computer science, but not so much for software engineering.

You need some math to be a project manager, but it's not complicated math.

Shannon Davis on April 1, 2009 10:43 AM

To follow up - reading more of the comments - I do think you need algebra and problem-solving skills - like the dreaded "word problem" is a perfect example of understanding a problem (requirements) and having to go through logical steps to come up with an answer (the solution).

I was thinking of math as either really high math, taught on college-level to math majors - beyond algebra and geometry. Or I was thinking of it was simple calculations. I know for a fact that you can't trust me to subtract double-digit numbers in my head. But I can solve a logic puzzle. It's the logic puzzle solving bit of the left brain that makes me good at what I do, not the ability (or in my case, inability) to calculate/compute sums quickly.

I guess it's like reading. Some people read slower than others. All programmers need to be able to read. But if you aren't a speed-reader, you don't get disqualified from the job.

Shannon Davis on April 1, 2009 10:48 AM

What you need to do is to look at a place where there is no math taught. I lived in a third world country where education was not something that was required and you realize that learning math whether it is something you use directly has an impact on how you think. It strengthens the brain and makes you a better thinker. I think this is HUGE in development of programers.

Davod2002 on April 1, 2009 10:48 AM

I programmed some Goertzel Algorithm based programs for frequency analysis, worked in fast fourier transforms for others, and did some simple frequency generation and mixed them with other frequencies to create tones... were all those things mathy?

I think they do teach math wrong... hence why I would reteach myself. With the kids I tutor, I see how they're currently teaching, and it's really just "the method" for solving a problem, and not how to critically think and solve the problem yourself, which is what I *try* to teach when tutoring.

The_Voice on April 1, 2009 10:57 AM

"... the vast bulk of code that I've seen consists mostly of the "balancing your checkbook" sort of math, nothing remotely like what you'd find in the average college calculus textbook, even."

And I guess those without good mathematics knowledge and interest can keep writing checkbook balancing code -- so that I don't have to. Integration projects bring in money to live off of, but are not satisfying.

This whole article reeks of "first stage of knowledge"-style proclamations. (In this sense, the first stage of knowledge is "You don't know what you don't know." Second is, "you know what you don't know". Third is "you know what you know". Fourth is "you don't know what you know" -- you've internalized it all.).

Without mathematical sophistication, how can you possibly proclaim that it isn't necessary? Sounds a lot like all those flunkies who proclaim that a college degree "isn't necessary -- it's just a piece of paper!"

It isn't just about learning things just in time, which of course is an important skill. Mathematics is not just arithmetic, algebra, and calculus.

Rick Brewster on April 1, 2009 11:02 AM

I'm liking the April Fool. Really well worked out, almost believable. Nicely done, sir!

John on April 1, 2009 11:10 AM

To add on to my little rant above, it's interesting that you recently talked about "five dollar words" with such passion: <a href="http://www.codinghorror.com/blog/archives/001244.html">http://www.codinghorror.com/blog/archives/001244.html</a>

"They are a bit off the beaten path. Words you don't hear often, but also words that provide the thrill of discovery, that "aha" moment as you realize a certain programming concept you knew only through experimentation and intuition has a name."

And now you are completely espousing academic proficiency.

Now, math is more than just a vocabulary. But, the concepts and ability to think of problems -- even seemingly trivial ones -- in terms of higher-level abstractions is valuable. This is very similar to learning that stuff you've hacked out in code has a very real, formalized design pattern that someone else already invented.

For example, the broader industry is just now waking up to how awesome functional programming is. Did you know that partial derivatives are analagous to higher-order functions, which are enabled in programming by things like closures? I've recently connected many of these concepts to create an asynchronous programming pattern/library which is not only mathematically sound, but casually approachable. And I'm using it to do some wicked stuff which is hardly "balancing your checkbook."

Being able to "connect the dots" between topics which are unrelated at an unsophisticated glance can help you build and strengthen your understanding and competency of even small or simple tasks/ideas.

It's like reading the book, "The Physics of Immortality" ( <a href="http://www.amazon.com/Physics-Immortality-Modern-Cosmology-Resurrection/dp/0385467990/ref=pd_bbs_sr_1?ie=UTF8&s=books&qid=1238609746&sr=8-1">http://www.amazon.com/Physics-Immortality-Modern-Cosmology-Resurrection/dp/0385467990/ref=pd_bbs_sr_1?ie=UTF8&s=books&qid=1238609746&sr=8-1</a> ). Yes, the premise is ridiculous, as is the conclusion. But everything in-between is highly edifying and challenging, and will teach you some new ways to think about things. (Not to say that math has a ridiculous premise or conclusion.)

Rick Brewster on April 1, 2009 11:20 AM

"Maybe I'm a hopeless optimist, but I think most programmers are smart enough to learn whatever math they need just in time to attack the problem at hand."

Yes. But then, ... they'd better be good at it, no?

BTW, Jeff: Just because you never read Dijkstras original articles doesn't mean that Dijkstra didn't write them:

http://www.cs.utexas.edu/users/EWD/transcriptions/EWD00xx/EWD51.html

Vinzent Hoefler on April 1, 2009 11:30 AM

Dijkstra also said that computer science is as much about computers as astronomy is about telescopes.

Every computer scientist should read Concrete Mathematics by Knuth et. al.

Every good computer scientist should read Calculus by Michael Spivak.

Knowledge of mathematics is essential to all but trivial development. While all of the basic algorithms have been offloaded to library functions, this means that one has to be all the more careful when adding more complex functionality. Without the knowledge of mathematics, you are just a stargazer.

Disestablisher on April 1, 2009 11:34 AM

Dutch people write stuff in English because almost everybody in the Netherlands can speak/read English or at least one other foreign (mostly French and/or German, but Spanish is also quite common) language. Many of the lectures and written documents in universities are in English as to make them more accessible to the rest of the world.
If there is a meeting with a single non-Dutch speaker, everybody just switches to English.

If Dijkstra would have published his writings in his native language, most of the world wouldn't even know they existed, much less read them.

Jacco on April 1, 2009 11:43 AM

I agree with David A. Lessnau (comment above) itís not being able to calculate the square of a number without a square root function itís the process of developing a solution to solving a user requirement in the terms of a formal computer process. Math gives a person understanding in how to develop a solution for a problem, and to do the work necessary to complete the solution. Maybe the current lack of this knowledge, whether it be math or another type of problem solving discipline like engineering, accounts for the fact that that the average project exceeds its original deadline of completion by 100% or about two-thirds of projects significantly over run their cost estimates. I wonít even get into the fact of how many projects fail. Peter Drucker once said ìThe computer is a moron.î And the way we develop software projects today maybe we should rethink the whole idea of what make a good developer. We have lost the fact that Software Development is really engineering.

Roy W Bradley on April 1, 2009 11:50 AM

I see programming, any programming, as a subset of math. Algorithms are pure math. Functions... math. Variables, math. Recursion, math. Etc.

Even logic is contained in math. So, when programming, 100% of what I write is math.

In my opinion, you need to be good at math to be good at programming simply because both are the same thing. It's only sad that computers only understand a ridiculously small subset of math.

Eric on April 1, 2009 12:03 PM

I think you're taking the "should be good at math" too far. How many people do you know that suck at basic Algebra? I know tons, and *none* of them would make good programmers.

When I was a kid I was really good at math. But I'm talking about story problems in grade school kind of math. Programming is basically working story problems all day in a lot of respects. There were two or three of us in all my math classes growing up that were good at story problems. When we got into programming in high school, those few of us were the ones that picked up on programming easily. Most others struggled.

Good programmers being mathematically inclined is the same as saying good musicians/composers are mathematically inclined. Once you get past 2 + 2 and start having to visualize the concepts in your head to "get" math, then math becomes inherently right-brain dependent.

sliderhouserules on April 1, 2009 12:05 PM

I have direct experience here, with both!

I did horrible in high school math, and did not take trig, ever. I've been a web application developer for 10 years now making a great living supporting a family of 4. And I NEVER need math. What I do have, and what most employers want these days is people who can solve "business problems" and speak in English while doing so and then to implement those using the right tool for the problem.

HOWEVER! I want a change. I want to program in the context of the physical world (Games, 3D and AI). And that needs Math, lots of it. I had my first night of class last night in Math 095 (Algebra). I have a long road ahead of me. But, I'm having fun as Jeff said and looking forward to a year of Math (algebra and calc) and more beyond that.

Marc on April 1, 2009 12:11 PM

"This statement is highly inaccurate. Logic is a topic within math, and creativity is needed in proof construction, a core skill."
@Delmania Logic is a branch of Philosophy, not math. Study your history please.

I had a Math instructor once (many years ago) who loved disproving mathematical formulas to the class using Logic. He wanted us to know that the two are very different creatures. It would be more fair to say(although still incorrect) that math is a subset of Logic.

Wolfmandragon on April 1, 2009 12:24 PM

You think most programmers are smart enough to learn when they encounter it?
Man, I think most programmers are not smart enough to learn, period.
And most of us definatly won't notice when they do something crooked, let alone learn the better way to do this...
ANY skill set a programmer starts with is good, because the chances of him/her learning them are so so small.

I once talked to a friend of mine and asked the theoretical question of "what's more important the dev leads or the development manager?". I think I said the dev manager, but I take it back now (or a couple of months ago) - the dev leads which educate (force feed information) their programmers are much much more important, simply because there are so few of them around.

Ariel on April 1, 2009 12:26 PM

This being posted on April 1st, I can't quite tell if it's an April Fools post or not.

If not, here's my view: "Mathematically inclined" does not mean "mathematically skilled".

"Mathematically skilled" - good at higher-level math (Calculus and higher, as a quick example)
"Mathematically inclined" - able to think logically and reason out an answer.

People who are not mathematically inclined - whether or not they are mathematically skilled - cannot program worth a damn. They can't reason out an algorithm, let alone code it.

Izkata on April 1, 2009 12:27 PM

You don't be a wizard in math to be a good programmer, basic addition is sufficient:
2 + 2 + 2
"&lt;p&gt;" + "Hello World" + "&lt;/p&gt;"

or like this in C#:

StringBuilder sb = new StringBuilder();
sb.append("&lt;p&gt;");
sb.append("Bla bla");
sb.append("&lt;/p&gt;");

Programming is easy = dead easy!!!And there's a fine line between a genius and an idiot.

code monkey on April 1, 2009 12:31 PM

The first "truth" in Dijkstra's article (EWD498) is:

"Programming is one of the most difficult branches of applied mathematics; the poorer mathematicians had better remain pure mathematicians."

I think this gives a bit more context to the "truth" further down in that same article:

"Besides a mathematical inclination, an exceptionally good mastery of one's native tongue is the most vital asset of a competent programmer."

Scott on April 1, 2009 12:34 PM

It really is important to keep in mind that Mathematics is AT THE HEART of all the computers we currently use and the software that we use to program them. In fact before Computer Science departments even existed at universities, programming was taught by faculty from the Mathematics department.

Made significant contributions to the hardware architecture
design of used in modern computers:
http://en.wikipedia.org/wiki/John_von_Neumann

Constructed one of the most well known and referenced proofs in
computer science;The Halting problem:
http://en.wikipedia.org/wiki/Alan_Turing
http://en.wikipedia.org/wiki/The_halting_problem

Also, it's important to note that constructing a correct program is VERY SIMILAR to constructing a correct mathematical proof. In both cases you must prove that your program/proof is correct including edge cases such as malformed input/set of all real numbers to infinity,etc.

o.s. on April 1, 2009 12:38 PM

100% agreed. Professional engineering is much more like lego assembly with components than it typically is like doing calculus. The only reference books I actually have are all stats and math ones, not programming ones, and they are plenty sufficient when I need them.

Kris Wehner on April 1, 2009 12:42 PM

I think what the original author meant was that, when someone is good at math, not necessarily knowledgeable about a specific field in math, but has the brain to seek how and why of mathematical problems as well as knowing how to utilize the current tools and knowledge available to solve the math problem, or even to prove a formula is correct. It is similar idea in programming perspective where you have to think about how to efficiently and effectively design your code and algorithms to solve the business problem, or even just programming problems. Many of our current programming projects are just simply providing interface for data entry and validation. But to write much more complicated software, such as a database (oracle, sql server, ...), AI, .. etc, you will need to be able to formula your problem, develop steps and coming up with algorithms. Even a simple tetrix game ( we all know how to play that, but it takes a lot more to develop an engine to be able to support the game play) will take a lot of math-like thinking in programming way to do that.

Terry on April 1, 2009 12:42 PM


You don't really need to know math to write code, you just need to know how to apply it. My first love is 3d graphics programming. I have a 9th grade education, so the gap in the math education I have recieved and the math that is used in 3d programming is huge. So first I hunkered down and learned what a vector was, then I hopped my butt into the math channels on IRC and explained what I was trying to do, and can someone hook me up with a formula please?

Nothing to it. I think a monkey could write code. Logic is everything. I spend so much more time trying to figure out how to get my hands on something (like control 'a' relative to control 'b') than I do trying to figure out how to solve my problem that it's not even funny.

Quaternion Rotation still gives me fits though.

Micah Czar on April 1, 2009 12:43 PM

Oops, I should have used the words test in reference to programs instead of prove but the idea is similar. To mathematically prove that even the most trivial software is always correct is a tall task. If there are just 32 if statements in your program then there are 2**32 possible different states that your program can be in based on a statement being either true or false.

o.s. on April 1, 2009 12:44 PM

I've come a computer science major and I detest math... none the less, I took a whole lot of it. Way, way more than I ever use (assuming I even remembered how to use it).

It all depends on what area of computing you do... for most, I suspect a strong understanding of advanced math is overkill but absolutely nessassary for a select few.

Kris on April 1, 2009 12:59 PM

@Kris Wehner - http://www.thinkgeek.com/tshirts-apparel/unisex/frustrations/374d/

That's not engineering. That's what I script UML tools to do.

Pete Kirkham on April 1, 2009 1:01 PM

It is not "should be inclined", I think they are naturally. There are lot of parallels between maths and computer science. I see programming as a applied mathematics. Both are concrete problem solving. requirement is defined, input is defined and expected output is defined!. Computer Science is simply the math showing its omnipotent glory!

Prakash Gomathinayagam on April 1, 2009 1:03 PM

Ever work with a retaional database? Relational databases came out of theories of working with n-tuples in abstract mathematics. If you understand relational databases, that means you have a good working knowledge of at least some of that theory.

Object orientated programming can trace its language and fundamental concepts back to group theory in Modern Algebra. If you are good at object orientated programming that means you a good working knowledge of at least some of that theory.

At the hardware level, the real work of a computer is done by the transistor. The transistor is a physical representation of the boolean NOR operatotrs. I.e. The only actual work being performed by the computer is applying the NOR operator over and over, billions of times oper second. The rest is moving bits around on the bus. The NOR operator lets you build Boolean Algebra which in turn lets you emulate all the other operations on a computer.

Speaking of Boolean Algebra, have you ever written an IF-Then-Else statement or used AND or OR operators to check of build bit-masks? If so you were doing math operations that 99% of the public would consider above their heads.

Have you ever worked with a multi-dimensional array? In mathematics this is called a matrix, and there is an entire branch of mathematics devoted to matrix theory.

My point is that Mathematics covers a wide range of subjects. It does not stop and end with calculus. All programming, by definition,is applied mathematics. Which means good programmers must be, on some level, good applied mathematicians, even if they don't realize that is what they are doing.


R.B.Davidson on April 1, 2009 1:12 PM

[quote]My point is that Mathematics covers a wide range of subjects. It does not stop and end with calculus. All programming, by definition,is applied mathematics. Which means good programmers must be, on some level, good applied mathematicians, even if they don't realize that is what they are doing.[/quote]

Yep. It's not what they teach in high school math classes. Or even most college math classes. But it takes a similar mindset.

Actually, it sometimes seems like you need the mindset of a math [i]teacher[/i] to be good at programming. You need to break a problem down into simple steps that your student can apply to any of a certain class of problems to get the right answer, and teach those steps. The only difference is, the computer is usually better at following simple instructions, and it's way faster at it.

Ken on April 1, 2009 1:20 PM

Math requires a certain different set of skills from programming, but problem solving is the same in both. Ability in most modern math classes does not necessarily correlate with problem solving. There's an immense similarity in sitting and finding an approach to a problem, but they general diverge in the actual approach taken, and how one goes about implementing approaches.

I have done both math and programming competitions, and the sorts of things you try are far different. For example, in a programming competition, your first question is "Does brute force work?" while in a math competition, it is never the best option. In both you're trying to accomplish some task with minimal effort, and you have to ponder how to do it, but with a computer to do busywork, it changes your entire attitude towards a problem. Now, competitions may not apply directly to the fields as a whole, but it seems like a revealing example.

Basically, any good programmer that has trouble with math is probably having trouble with grasping the concepts for whatever reason, but they're still amazing problem solvers, and if they did understand math concepts, they could use them to amazing effect. Similarly, good mathematicians are also good problem solvers, and if they managed to grasp programming concepts, they could use them to great effect as well.

That said, there are of course domains where the concepts intersect, and you'd better know the basic concepts for both.

Accatagon on April 1, 2009 1:23 PM

You're missing the point.

Math isn't about numbers. Arithmetic is about numbers. Math is about logic. Programming is about logic. Being good at one necessarily means being good at the other, and improving in one necessarily improves the other.

For example, proof by induction should be a pretty simple concept for most programmers, but it's very difficult for a lot of non-programmers to wrap their head around.

I'm a math major, and I hate numbers. Most mathematicians, you'll find, aren't that great at doing arithmetic in their head. It's non-trivial for me to do subtraction on two-digit numbers in my head, for example. But just like programmers, mathematicians don't have to worry about that.

Every field of mathematics has a few base axioms. They're like a mathematical assembly language. Then we've got theorems and lemmas which are analogous to programming libraries. You don't need to write your own implementation of arrays every time you want to use them in a new program, and mathematicians wouldn't try to prove a complicated theorem on the natural numbers by starting all the way at the Peano axioms.

Asmor on April 1, 2009 1:43 PM

Jeff:

You seem to be refuting things that Dijkstra did not say (at least in this quote).

Dijkstra did not say "You need to learn math in order to program" he said a mathematical inclination is important. This to me implies a character trait, not a set of skills.

Jason on April 1, 2009 1:49 PM

I have defended this position before here, and didn't get much love them. :-)

Code is math. Not arithmetic, to be sure, but math.

When you speak of inheritance or interfaces, that's group theory. You might not know what the heck is group theory, but you are using it intuitively. And, of course, you might incur in errors when intuition fails, or you might reinvent the wheel (and call it Liskov Substitution Principle, for example).

When you use any flow control, that's automata theory. Again, you might not know the theory, but you are using it. So when something more complex show up, you might spend some hours rewriting your algorithm, or write spaghetti code instead of using a DFA, for example.

There's logic, which has been mentioned before. If you have seen incorrect usage of &&, || and !, that's math (or the lack of it).

There are algorithms, such as those used in linear programming, which might save you (or your user) time for what would have been simple tasks (such as optimizing load).

And so on.

If you write a program, you are actively using math. If you lack math, you waste time. Either your time figuring out how to solve a problem that has been solved before, your successor by writing code unnecessarily complex, or your user by writing code that takes longer to run than needed.

Daniel on April 1, 2009 2:34 PM

Dijkstra probably meant mathematics in the university sense, as he probably mixed with a lot of university mathematicians. University maths is nothing like the maths you talk about in your article. To have a mathematical inclination in this sense means being able to argue logically etc... and does engage a great deal of creativity. There are other parallels with programming, eg. there is no siuch thing as THE proof, there are just different proofs.

Rhys on April 1, 2009 2:36 PM

# They teach math all wrong in school. Way, WAY wrong. If you teach yourself math the right way, you'll learn faster, remember it longer, and it'll be much more valuable to you as a programmer.

This is the enlightening statement for the question you raised. And of course "What would be the right way to teach math?". I think the answer is quite obvious from the course of all discussion going on this topic.

Programming is the right method of teaching mathematics!

I will repeat this some more times to emphasis it:


Programming is the right method of teaching mathematics!

Programming is the right method of teaching mathematics!

Programming is the right method of teaching mathematics!

Programming is the right method of teaching mathematics!

I was never interested in math when I was a kid. But I was very interested in computers and programing. I got really interested in maths when I went to university (studying physics). I was just fascinated by the beauty of mathematics and from that time on I consider myself being quite good at maths. What I am beginning to understand as the time goes by is that I learned mathematical concepts incredibly fast. And there is two reasons for that:
1) I am naturally mathematically inclined.
2) I studied programming when I was a kid.

Concluding all I just said in one sentence:

Abstract mathematics is the just the next level of abstraction that a person familiar with algorithms and his native language have to master.

Evgeni Pandurski on April 1, 2009 3:15 PM

Hell, Algebra I involved creativity. Mainly because I was new to it and had to put the pieces together on tests to get from problem to solution. After I'd been at it a while, I just remembered the steps that I had previously had to re-reason from... well, not first principles, but from as much of the introductory theorems and whatnot as I could manage to remember on test day.

That same process serves me very well when I put code together.

Ken on April 1, 2009 3:18 PM

So, I need to know:
1) Programming wizardry
2) Hardware mumbo-jumbo
3) Software Engineering alien language
4) Network voodoo
AND
5) Math magic?

Seriously now, you are asking too much of me.

Hoffmann on April 1, 2009 3:25 PM

You either are :

- a good programmer mathematically inclined
- a good programmer artistically inclined
- a good programmer socially inclined (the loud ones Mr. Jeff)
- all of the above
- not a good programmer

Conclusion: you can't be a good programmer withouth beeing good at something else besides programming.


Pop Catalin on April 1, 2009 3:39 PM

Wow! I can not resist the temptation to write one more post on this subject :) Actually this is a kid of proof to my theory that "Programming is the right method of teaching mathematics!".

We all very well know that mathematical theory developed very fast after the push in the right direction Newton's gave to physics. Well I think that what Newton really did is that he wrote a program for the celestial objects to run! I know it might sound silly but that's exactly what Newton did. Lately this program were to became "The law of gravity" because strangely lots of objects strictly followed Newton's program. Nevertheless Newton had no way to know this. It is mere coincidence that nature can be described by some simple programs someone wrote!

Imagine if Newton had learned math in school... Would he have the courage to tell planets how to move :)

Evgeni Pandurski on April 1, 2009 3:43 PM

Math is to arithmetic as programming is to software development?

Surely there's a big difference in the math skills required to create a compiler in C and a say a database reading script in PHP.

17B at hand on April 1, 2009 3:46 PM

well

set theory is what underlies databases but for "comercial" programming you dont realy need Maths.

Technical programming you do let me give you an example at my first job we where researching fire sprinkers and I was given part of the task of working our how to locate the droplets in 3dspace.

The companys photographic dept and the electronic shop came up with a way of gett8ing the z dimension used cameras with a very tight depth of filed and two colored flashes to effectively take pictures of a plane through the z dimension. The two flashes had a delay so you got two coloured images of each drop let

We brought an A0 digitizer from Ferranti (this is in 81 ish) I had to write a custom driver that ran in the back ground of the PDP11 then work out how to calibrate the tablet. And then write the software that was used to digitise the drop lets (as this is 1980ís we got a RA to pick out droplet pairs )

Thatís a case when you do need to understand maths.

Neuro on April 1, 2009 4:08 PM

oh and I did write the software in FORTRAN

Neuro on April 1, 2009 4:09 PM

I agree that for most programming tasks higher level maths is not required as libraries are already written for more complex pats. However the shear fact of having this knowledge shows you are more intelligent and makes, your knowledge of the simpler stuff much more embedded.

Learning at a higher level pushes you, once I had done degree level maths I found everything I had done before became easy such as differentiation, integration... Which at the time I found difficult.

I completely disagree on a mastery of ones tongue being important, otherwise how do you explain the high proportion of dyslexic programmers who tend to be very good.

pete on April 1, 2009 4:10 PM

I think that the key word is "inclination". It's not so much that a programmer should be good at math, but he should have an understanding of mathematical thinking.
Think about a program that has nothing to do with math. Imagine you don't even need to handle sets or relationships, of at most basic math functions. Say the program recieves a list of numbers and adds them all together. It's true you don't need to be a mathmagician to do that, but you do need to have a mathematically inclined mind to be able to abstract the problem into a loop. You need an extremely mathematical-like mind to be able to track bugs.
Both Math and Programming do the next: define a series of steps that given something A always give out B.
Both Math and Programming can be wrong, but math has an extremely elaborate system to find out where the problem is. This hasn't always been so, or the greeks would have realized that irrational numbers HAD to exist much sooner.
I would say that you don't need to understand set theory or relationships to handle a database, though relational databases are based on this math.
You don't need knowledge of statistical analisis or probability theory to configure your server, though it'd help in getting the optimal configuartion.
Programmers and mathmathicians think in many similiar kind of problems so it's obvious that programming uses mathematics as a foundation, mostly because mathematics has thousands of years tweaking and perfecting it's art, programming has about 100 at most. This is the only reason I can think of why a programmer should have a solid enought understanding of basic math (geometry (and trigonometry), algebra, probability and statistics, and maybe some calculus).

Charlie Lobo on April 1, 2009 4:21 PM

I agree with previous comments that Web programming, like Visual Basic, normally isn't hard core programming.

Not to diminish it - it is a powerful, useful medium with complexities of its own. But it is hardly low level stuff. Maths is almost essential for low level stuff, when pointers, memory management and optimisation are important. Web programming is higher level and, in a way, no less difficult but much less Maths oriented.

So the mistake is in saying "programming" and "maths", which are both too broad. It's like saying you need "science" to be a doctor. Sure they need to know biology and chemistry, but do they really need to know quantum mechanics? For specific programming areas, specific maths skills are required. A security programmer needs to know cryptography but probably doesn't need to know finance formulas.

Philip on April 1, 2009 4:34 PM

Without having read the specific context of Dijkstra's Turing lecture, I should note that he was an advocate of a highly mathematical style of programming, where the programmer would build up a proof of correctness while writing the code. Each loop that you wrote was supposed to have its own little induction proof, in which you show that the loop maintains its invariant for each iteration, and that the postconditions follow from the loop invariant and the preconditions. I don't know anyone who actually programs that way, but he did advocate for it in at least one of his books, and the implications of that belief do show up elsewhere in his writing.

Dave W. on April 1, 2009 4:37 PM

Ugh, yes. Math.
I have such a poor mathematic background but I love the complexity and interconnectivity of programming. A week ago i spent two days trying to write an algorithm to make a curve. I gave up, then some one told me how to do it...

log2(x)

Boy did I feel stupid. At least I got it working, eh?

Nesetalis on April 1, 2009 4:44 PM

Math teaches you to abstract, to extract from a problem or system its fundamental questions. This is crucial to designing systems well. Now that does not mean that you cannot learn abstraction elsewhere. A formal math education is something like becoming a distance runner. It makes other things far easier.

As for specifics: optimization is a matter of minimizing a given metric. What metric? For that matter, what is a metric. Go learn a bit of topology.

Many optimization algorithms (while we're on the topic) are simple linear algebra. Of course it's only simple if you know a bit of abstract algebra and then learn linear algebra.

Numerical approx. is all calc, diff eq & pde. What's the diff between various definitions of integration, and how do they resolve poles?

Want to implement a codec? You'll probably need to know some non-trivial number theory, finite group theory, and perhaps even finite geometry.

And so forth. The interesting areas often involve math. The boring ones, not so much.

Cheers,
Scott

Scott Swank on April 1, 2009 4:54 PM

And then there's the very strong motivational relationship between functional programming and category theory. If you've never heard of a category, functor, modad (monoidal category), or natural transformation you'll struggle more with functional programming.

Scott

Scott Swank on April 1, 2009 4:57 PM

"set theory is what underlies databases but for "comercial" programming you dont realy need Maths."

You don't? I haven't run across too many commercial programing projects that didn't involve a database. And if you haven't got some understanding of set theory, how is your code going to interact with the database? Poorly.

Ken on April 1, 2009 5:53 PM

Weird timing. I have always been abysmally bad at math. About 10 years ago I started programming. Now... in my 30s I am back in college trying to get a degree ... and I have to take Algebra. I am finding it MUCH easier to learn this go round.
I don't think that math skills are all that much of an asset to your average everyday programmer who does nothing more than shuffle data from one field or database to another, but I can see if you are writing a 3-d library, financial analysis software, or low level software where you have to know how to make a computer perform multiplication without using the "*" operator.

Back a long time ago I had to write an ad for Honda that grabbed a long/lat and found a point like.. 623 miles away or something, the math for computing the curved surface of the earth and the distance between long/lat points was ridiculous. I didn't write the algorithm, but I did have to translate it to the language I was using and test it.

Good times. ....

Jerz on April 1, 2009 5:58 PM

Lower mathematics, such as the calculus we took in first year, is no more than plugging numbers into formulas. It's the same as implementing someone else's algorithm. Higher mathematics, however, needs the same thought process as constructing elegant algorithms. I think those who never took higher math can't understand what Dijkstra said.

nobodynobodyghost on April 1, 2009 6:11 PM

That question has been asked, and responded, over and over everywhere...

Here's a little analogy: if virtually none knows how to make a mechanical clock yet, shouldn't the process of designing and manufacturing one be approached in careful, logical measurement?

Dijkstra's time is the Stone Age to our Bronze Age. With the absence of any physical law to fall back on, and primitive programming environment (hardware, language, software tools), math is the only primary device available, back then, to cope with the complexity of constructing software.

Any way we want to interpret his remark in the context of our own era, it doesn't diminish math's importance to the development of computer science.

Adhi Hargo on April 1, 2009 6:12 PM

I am always looking for that mathematical insight that might help me create that elegant solution to some programming problem I am working on. It's the same thing with programming puzzles. I am waiting for the day that I will have to sacrifice ten people to find out which one of my 1000 bottles of wine were poisoned. So it's really all about making this information practical and useful.

Tone on April 1, 2009 6:53 PM

Jeff, you are misunderstanding Djikstra.

Programming *is* maths. Programming is an application of Computer Science, and Computer Science is a branch of mathematics.

Do not think of maths as simply being Calculus and "stuff to do with numbers". Algorithms, type systems, data structures are all parts of maths, and I don't think you'd disagree that knowing these things is incredibly important to being a good programmer.

Peter Alexander on April 1, 2009 7:15 PM

It looks like Jeff is confusing math with arithmetic. A mathematically inclined person who is also good with languages can think abstractly and turn those abstractions to concrete implementations.

E.g., someone who doesn't understand set theory is bound to misunderstand what relational means in the phrase 'relational database'.

Sinan on April 1, 2009 7:16 PM

For people asking about the right way to learn math. Have a read of http://www.maa.org/devlin/LockhartsLament.pdf

Grom on April 1, 2009 7:48 PM

A possibily illustrative analogy for the relationship between programming and math: breeding and genetics.

You can be an expert breeder without any knowledge of genetics - people have done so for generations. However genetics brings both a depth of understanding and a brodening of scope to the field. (You can't clone a sheep through traditional breeding techniques)

This is what math brings to programming - understanding and brodening of scope. One can program competently using only intuition and experinece, but one can do so much _more_ with mathematical knowledge in hand... and would actually understand what one is doing, in a fundamental sense. ^_^

Of course, the analogy breaks down when you consider that computer science is founded on mathematics, while breeding precedes genetics by centuries.

SytS on April 1, 2009 8:04 PM

Here's the Dijkstra book I was mentioning earlier:
http://www.amazon.com/Discipline-Programming-Prentice-Hall-Automatic-Computation/dp/013215871X
I think the user comments give one a flavor of the book.

As I said, I don't know anyone who actually programs that way, even those with a mathematical orientation. It's an interesting read if you want to understand the way Dijkstra thought, but I wouldn't give it a very high priority for a practical personal library, unless you want to know a lot more about proofs of correctness. Dijkstra was a very bright guy who made a number of original contributions to the field, but he also had some idiosyncratic opinions that haven't stood up all that well to the test of time, and he had an evangelist's faith in the truth of his own opinions.

Dave W. on April 1, 2009 9:04 PM

Peter Alexander wrote "Programming *is* maths. Programming is an application of Computer Science, and Computer Science is a branch of mathematics."

Algorithmics, a branch of Computer Science, is about Space and Time computational complexity. Space and Time are part of physics, not math. There's no known mathematical definition of Time yet.

Algobum on April 1, 2009 9:36 PM

I still use my fingers for math. Perhaps that is why I not so good programming?

chrystal on April 1, 2009 9:57 PM

>>For many pupils, the most difficult part of a math test are math story problems. They give you a story, a specific example. Your task is to transform it into an equation (or a set of equations), an abstract description. Once you have done that, solving the equation is usually trivial.

Completely agreed here in the States. I earned a little extra money by tutoring Chemistry and Physics, and almost always found that my students' issues were in how they translated English into Math.

But I digress. I propose the following - general math education has historically been the way to show how to translate generalized, "fuzzy" instructions into concrete steps, much like translating word problems. Good code represents the concrete steps, and the job of the programmer is to do the translation.

I would argue that skill at math isn't necessarily the real issue, but the ability to concretely express fuzzy concepts is, and that skill with algebra in particular is highly correlated with this even if they are not quite the same.

Jeff on April 1, 2009 10:04 PM

I've never needed high-level math in any of the programming projects I've had (not even in school!). But based on my personal experience, math has helped me to become a better programmer because it taught me how to have the proper mindset. Nothing taught me better to logically think out of the box and to patiently sit on a problem than proving trigonometry equations. Math helped me think more efficiently.

Oyen on April 1, 2009 10:11 PM

"Math is a lot easier to pick up after you know how to program. In fact, if you're a halfway decent programmer, you'll find it's almost a snap."

It's a wonder that computer programmers didn't resolve the Poincare Conjecture, Thurston Geometrization, Fermat's Last Theorem, Atiyah-Singer Index Theorem, Classification of Finite Simple Groups, Taniyama-Shimura conjecture, motivic cohomology, Monstrous Moonshine, etc. in their spare time. The Riemann hypothesis, on the other hand, might take a month.


innocent bystander on April 1, 2009 10:20 PM

I'm hoping this is a joke for the 1st of April and not sincere -- I would prefer to maintain some respect for your opinion. However, as most of the comments seem to be falling en queue behind your sentiment, I shall address you as though you meant every word.

"He's got the right idea; if we're going to talk about math, let's get out of the abstract and into the specific. Let's talk details. Examples. What could be more math-y than that?"

Wow. You quite obviously have NEVER studied any true mathematics in your life. I generally find your articles at least passingly interesting. But this merely betrays a very deep ignorance of the study of mathematics and only the most shallow understanding of the field. Anyone who talks about math in terms of high school algebra or arithmetic is wholly unqualified to discuss the subject. In my opinion, most of the computer science students with whom I've worked have a profound lack of understanding of mathematics; so, you are not exceptional. Their inability to conceive of the depth of that field, however, is often a noticeable detriment to their facility for understanding more advanced and, yes, abstract subjects and ideas in computer science, design, architecture, or, well, you name it. Despite this prevalent and accepted ignorance, many computer science students laughably believe they have a good understanding of mathematics. Please, re-visit this subject when you can hold a conversation about the topic of the latest Field's medal recipient's work. And before you respond to ask the same, do some research on the backgrounds of the greatest minds in computer science -- I believe you'll see a great deal of mathematics.

Jeremy on April 1, 2009 10:23 PM

A very interesting discussion. To me, mathematics is a way of thinkin too, just as programming is. I am no mathematician, but a math lover and I have been a business application developer most of my life so far. As long as you don't see math as equations / formulae / theorems & their proof, but instead see it as problems / abstractions / solutions / application, I don't see why it is any different from programming.

Agree, you don't need calculus / trigonometry to do purchase orders and account statements. But the midset required to go through upto calculus and see how it fits the real world solutions is the same mindset required to follow through a customer's problem and translate his solution to an efficient program.

Anupama on April 1, 2009 10:29 PM

http://news.ycombinator.com/item?id=541753

asa-moe on April 1, 2009 10:42 PM

IMHO, the first quote expresses this best: You need a mathematical inclination, i.e., a general willingness and capability to do math. The rest happens automatically. And, as the first quote also shows, it doesn't end there, it only starts with that.

As for what I do with math: Try doing any graphics-related programming at all without a firm grasp on the basics of coordinate systems. Many programmers already fail at determining if "+1" is going left or right.

Take Java, for example: It's AWT drawing model is exactly defined (thus very predictable, and even correct -- never encountered a bug in those specifications), but you need a mathematic thinking engine to understand it correctly. You don't even need to know trigonometric functions or square roots. But you need the capability to think math-y.

Moe on April 1, 2009 10:47 PM

That's not his Turing Award lecture!

It's here:

The Humble Programmer

http://www.cs.utexas.edu/~EWD/ewd03xx/EWD340.PDF

Mark Harrison on April 1, 2009 10:49 PM

Grom: I find myself in violent agreement with at least half of Lockhart's rant, and in violent disagreement with the rest. I absolutely agree that we need to do a better job of motivating math education and including more of the history of math in math class, rather than just teaching it as a random collection of facts and techniques, as it too often is today. But, speaking as someone who has volunteered as a school math tutor in middle and high school, I think he underestimates the value of mastering the techniques themselves.

Our school district uses a Geometry text called "Discovering Geometry" that follows along the lines he recommends. It's very much an inductive, experiential approach, trying to teach Geometry as if it were an experimental science. To teach kids about the volume of a pyramid, it has them push model pyramids into cups of sand and measure the amount of sand displaced. It encourages them to try and find a pattern in the results. But nowhere in the main text does it actually give them the formula for computing the volume. If they don't figure it out in the lab, they don't learn that bit of information. (It does make passing reference to the formula in the answer to one of the odd-numbered questions given in the back, but not where a kid trying to study for a test will find it.)

My experience with that book, having seen it taught by two different teachers, is that it can work in the hands of an exceptionally good teacher, who uses the book as raw material, but reworks it and supplements it with a lot of her own handouts. But in the hands of a less talented teacher (not necessarily a bad teacher, just less inspired and more closely following the text), it was a disaster. She might write the pyramid formula on the board, but any kid who didn't copy it down into his or her own notes was screwed. You couldn't study from the book, because it didn't bother to tell you which possible facts were correct. "What do you think?" may work for poetry interpretation, but it's a pretty lousy way to teach a subject where there are clear right and wrong answers, unless you use it to motivate initial curiosity while giving the kids the right answer later.

And having tutored some kids in a remedial algebra class for a semester, I saw how many of the difficulties kids had with algebra were related to flaws in their basic arithmetic techniques. It's easy to say that kids can always use calculators for arithmetic, but I saw kids who had trouble factoring polynomials because they couldn't factor anything bigger than a single-digit integer, or because they had trouble understanding how to add positive and negative integers together. And factoring polynomials is important, not just because it's part of the standardized tests, but because it's a basic manipulation that is needed for a number of those derivations and proofs that he hopes kids can discover on their own.

So sure, we need to revamp math education and do a better job of tying the stuff we want to teach together with its history and the problems people were trying to solve when they invented this stuff. But I think it's a serious flaw to neglect to teach basic techniques solidly.

Dave W. on April 1, 2009 10:56 PM

Math or no Math...
it doesn't matter anymore..

UNKNOWN on April 1, 2009 11:07 PM

I expect 'the math requirement' is due to the origins of programming. The first essential use for computers and thus programming was to solve complex mathematical or physical problems (enigma, Manhattan project, moon landing). You can't really solve partial differential equations with a computer if you do not know how to do them by hand. E.g. error estimation of numerical methods do require some math.

Now programming is ubiquitous. I think it was Clay Shirky who compares it to typing. There are hardly 'typists' anymore, and soon there will be no more 'programmers'. Of course there will always be people writing compilers, but most 'coders' will be people writing tools for their not-so-mathematical profession. (See also todays post on www.freedom-to-tinker.com about programing for law professors.)

The most important thing programmers should know is the 'big O notation' I think. But this mainly trickles in through 'leaky abstractions' (see Joel's Spolsky's article), which might improve in future programming languages.

Personally, as an astronomy PhD student, math is kinda required. But again not as part of the programming an-sich, but for the things to actually implement. (All in English BTW.)

BertBert on April 2, 2009 12:16 AM

You might not need actual mathematical theories or constructs in day-to-day programming, agreed. But it seems evident to me that a strong analytical background and thinking is a big plus, even a must for good programmers.

So I don't think "mathematically inclined" is to be interpreted too narrowly, but rather in the sense of having an analytical view of the world and the problems to be tackled. A natural reflex to view a problem in terms of its technical solution is just the foundation a good programmer needs.

wwwald on April 2, 2009 12:22 AM

While a programmer doesn't necessarily have to know calculus and the like, it's crucial to know and do all the pre-calculus stuff correctly, to know the numbers as they are in the purely abstract domain and in their purely concrete and limited incarnation in the computer hardware and software. Somebody who doesn't know if he should add 1 to a value or subtract or do something else to index the right array element can never be a good programmer. Somebody who doesn't care about overflows, underflows, and loss of precision can't be a good programmer. Somebody who can't estimate the complexity of their own code can't be a good programmer. Those who can't pay attention to detail can't be good programmers. Somebody who can't prove their code is right mathematically/logically, by a good test or a combination of them can't be a good programmer. And a good test often times assumes some good math background or math inclination too.

I have seen so much crappy code, it's unbelievable. And often times it was crappy because it was written inattentively with very lax math and the authors never bothered to actually prove its correctness or adequately test it. They just hoped it would work and it appeared to until put under scrutiny.

My math background and inclination has helped me to understand and correctly implement well-known algorithms, modify them to suit my needs, invent my own algorithms, write mostly correct code, debug code, test and review code (not only mine), find bugs in code, optimize code. Had I not had that, I would've been a disaster, not a programmer, let alone a good programmer.

Anonymous on April 2, 2009 12:25 AM

And I even dare to say, programming isn't for math challenged.

Anonymous on April 2, 2009 12:28 AM

//I think most programmers are smart enough to learn whatever math they need just in time to attack the problem at hand.

Have to totally agree with you...

Jaskirat on April 2, 2009 12:31 AM

"no one has ever tried to localize..." I had to stop reading right there. You should be teased about that one for a long time. Please tell Joel that you deserve to be the but of a joke on your podcast.

Theres 10 localized symbols for 3 on this page:
http://en.wikipedia.org/wiki/3_(number)

Ian on April 2, 2009 12:53 AM

Jeff... You sound EXACTLY like those people in the TV show "Numb3rs" who complain that "maths won't help us catch this killer".

TraumaPony on April 2, 2009 1:03 AM

"no one has ever tried to localize..." I had to stop reading right there. You should be teased about that one for a long time. Please tell Joel that you deserve to be the but of a joke on your podcast.

Theres 10 localized symbols for 3 on this page:
http://en.wikipedia.org/wiki/3_(number)
Ian on April 2, 2009 12:53 AM

Jeff PWNED...

:)

UNKNOWN on April 2, 2009 1:29 AM

Do mathematicians believe in god?, i Know programmers do...
:)

UNKNOWN on April 2, 2009 1:30 AM

Guys, give jeff a break..whatever he writes on blog need not be 100 % accurate and correct all the time...if he learns that something is wrong he will correct it..
after all he is also a human being and a fellow programmer...he also makes mistakes just like any one of us...
so go easy on him..


UNKNOWN on April 2, 2009 1:52 AM

To the people who think it's always ok to learn the maths just in time: Let's compare this to physical skills.

Would you take anyone seriously if they said they'd learn to swim just before taking a job as a lifeguard? Or someone learning to sew when they get a job as a seamstress?

Some minor maths you can pick up on the spot, but many tasks require too big a chunk of maths to learn like that, and almost anyone who thinks they can do it is simply overestimating their own abilities. (Sure, our lifeguard friend can learn to swim in a week, but he'll be rubbish at it, and he's not going to save anyone's life).

mac on April 2, 2009 2:10 AM

Learning math made me a lot better as a programmer.

Hell, once I was trying to figure out a physics problem in a commercial piece of software I was writing while in college, and realized the solution was actually held in the calculus lecture I'd attended the day before.

Don't underestimate math at all.

Bill on April 2, 2009 2:14 AM

@Grom..
For people asking about the right way to learn math. Have a read of http://www.maa.org/devlin/LockhartsLament.pdf

Really Excellent article..
I now understand the beauty of math...forget programming...i love math now..
i have wasted 13 years of my schooling in the math..OMG...

UNKNOWN on April 2, 2009 2:34 AM

one more thing..
MATHEMATICS IS ART AND SO SHOULD PROGRAMMING BE...
WE ARE DOING THE SAME TO SOFTWARE ENGINEERING AND COMPUTER SCIENCE..THAT WE DID TO MATHEMATICS IN SCHOOL...
WHAT A SHAME!!!

UNKNOWN on April 2, 2009 2:37 AM

from my experience during college:
people whose really good at math (by I mean really good, they really are like born to be a mathematician, not just someone whose diligent enough), they learn about how to code faster (much faster actually) than someone whose just have an average math skill.
I think it's because programming mostly are about abstract thinking and reasoning, something that a mathematician's brain used to.

siroj on April 2, 2009 3:02 AM

The one job where I really used some of the (multitude) maths from university was my first, where I worked with music DSP software. Apart from that, knowledge of boolean algebra is always useful and set theory applies to database design. I do however belive that studying mathematics developed my analythical skills, which I use every day.

Jens J on April 2, 2009 3:08 AM

I see maths as a "metalanguage" build on a natural language. Mathematicians redefine terms (tree, family, free, kernel, etc.) which have their mathematical meaning and relationships. it goes from simple redefinitions to complex theories.

On the other side, science (like physics) tries to modelize the world: it goes from complex to simple; which also helps the computer scientist (see domain driven design for example)

IMHO, mastering the math metalanguage as well as the physics modelling help the computer scientist.

StÈphane on April 2, 2009 5:16 AM

Writing a plotting api [1] is a good example of where one might need some math. Trigonometry, Hermite curves, boundary calculation, etc.

[1] http://linil.wordpress.com/2008/09/16/cairoplot-11/

Rodrigo Araujo on April 2, 2009 5:34 AM

Programmers don't need to be mathimatically inclined, but they also shouldn't be adverse to math. When a programmer tells me they're not into something (like math) I think that's a shame. I can't relate to them anymore. Why exclude a whole block of subject matter b/c you're not interested in it or afraid you won't be good at it. You said we should constantly be learning, that includes math, it excludes nothing.

Mike on April 2, 2009 5:43 AM

Math at the very least trains analytical thinking and problem solving. Most of the, I change that, all of the great programmers that I've worked with were really good at math.


Kimbo on April 2, 2009 5:50 AM

"if we're going to talk about math, let's get out of the abstract and into the specific. Let's talk details. Examples. What could be more math-y than that?"

Yeah, what Jeremy said about this, except that I'm not certain you don't know what you're talking about... it could be just a slip of the tongue.

Out of curiosity, are you really familiar with upper-level mathematics? I hope so, because otherwise you are writing a review of a tool you have never used.

Ian Maxwell on April 2, 2009 6:13 AM

It is the other way around today.

Should competent mathematicians be "above average programmers"?

dbasnett on April 2, 2009 6:18 AM

I remember that when we have learnt Gaussian elimination at school, I was absolutely convinced that I never ever would use that in my future life again - OK, then I didn't know yet that I would make my living as a computer programmer. Then, at a web (!!!) development job many years ago, I had a complicated 3x3 system of linear equations, remembered the algorithm, but not the name - it was with classic.asp, and I solved the system by hand. The result was 2-3 screen pages of algebra and dozends of pseudo unit tests verifying the intermediate formulas (some of them failing due to rounding problems) - but the software worked. Later, I discovered that there exists software called "CAS" or "computer algebra system".

Now I'm working on an asp.net intranet web app at another company, and I had a hard time trying to convince my boss that a linear equation with boundary value constraints for some variables is not linear no more and cannot easily be solved for another variable. I ended up with a mixed solution, partially algebraically solved, partially with an iterative approximate solution. The dissent remains, but as long as the results are OK, there's no point in going through the profoundities of implementing inequality solvers (no, things like that don't exist at all in the sooo cool .net library).

What sometimes drives my crazy is the absolute impossibility to explain the unsettling primitivity of the so modern state-of-the-art best-of-all-worlds .NET framework (using C#) with regard e.g. to linear algebra (I must admit that I have studied computational linguistics at university where we have learnt Prolog) to most of todays programmers. They even claim that a function returning a delegate is "a function returning a function" ("Ever heard of C pointers?" "Yes, that existed in ancient history. Delegates are sooo much better, really the ultimative thing!"). These are the people which will never grasp what a CAS is for, which never have seen the beauty and usability of 4GL KI languages like Lisp and Prolog (&#8222;These are only for scientific purposes!&#8220;).

But that's why I always was the programmer who was charged with those programming tasks these people couldn't accomplish at my former job (which I left for differen reasons).

tarnold on April 2, 2009 6:49 AM

@dbasnett I think you are starting to get to the nub of the issue. The biggest math nuts I have ever know were impossibly awkward when it came to real life problems.

I suspect that the proposition needs to be reversed. While mathematicians may claim logic as their own, applied logic (and common sense) is, I suggest, the lingua franca of all the great programmers/system developers.

Mathematical skills are too often equated to a very limited set of capabilities, far short in my mind of the skills required to be a truely great programmer.

Even "programmer" is, in my world view, not what we are talking about. We are talking about people who can enter chaos, see patterns where others see noise, and then reduce their understanding to an algorithm - or implementation - that a machine can repeatedly perform for the benefit of others.

There is nothing inherit in that process that requires specific mathematical ability (although it may, in certain domains). The core is logic and pure reasoning ability.

Which is why - and I offer myself as a great example - we find programmers who are effectively multi-lingual in many programming languages, but struggle with even one additional human language. Programming languages are in effect just subtle variations of an expression of distilled, pure logic, whereas human language is in only the most superficial sense logical.

I love human language, and always wish I spoke many more than I do; but in learning languages, and leaning programming, I recognise the two share nothing other than the vulgar use of the word "language".

Paul on April 2, 2009 6:58 AM

I agree that COMPETENT programmers don't need to be mathematically inclined, however, one will never be a skilled* programmer without great math skills.

* read: able to code efficient and robust software.

How else would you (just a few examples):
- Put several controls in a UI container and move around them in columns and rows on a resize.
- Update the hue or color on a progress bar or other mechanism depending on status.
- Use user selection on an array of items to affect bit-type flags using 2 to the Nth power.

Sure, you can use conditional statements or other mechanisms for this, but then it's neither efficient to update and sometimes to run, nor is it robust: i.e. doesn't require logic code changes to update.

In short, math over conditionals or other similar mechanisms doesn't require the logic to be updated when expanded. Use these lesser methods and you will be competent. Use math, and similar forward thinking approaches, and you will be skilled and your software will be smoother, sleeker, and easier to update.

David on April 2, 2009 7:03 AM

"Mathematically inclined" is not to be confused with "knows math".

By "mathematically inclined" Dijkstra meant "having the kind of intelligence that would allow one to do well at math if one had the need or desire to do so." Not because one needs to learn math to do programming, but because one needs the same kind of intelligence.

The thought processes involved in constructing a mathematical proof are similar to those involved in constructing a program; the thought processes involved in finding the flaw in a proof are similar to those used for finding the bug in a program. The same thought processes used in polishing a proof to make it more elegant are used in refactoring a program to make it simpler and easier to understand and modify. The same thought processes used in learning a mathematical notation are used in learning a programming language or API.

Frank Silberman on April 2, 2009 7:40 AM

Programmers maybe, but what about configuration managers or such?

Silvercode on April 2, 2009 7:50 AM

The Dijkstra quote is that programmers should be mathematically *inclined*. I think the point was not that they be know a lot of math or even that they like math, but that they are the sort of people that, if motivated, are good at learning and understanding math.

I just noticed Frank made the same point above... ::sigh::...


Hank on April 2, 2009 8:02 AM

There is such a strong disagreement about terms, and no one's mentioned it.

If you're talking about basic arithmetic, sure. Everyone needs a fundamental understanding of the stuff. If you're working on a computer, a decent understanding of binary representation / operations (and a very good understanding of floating-point limitations) is helpful.

But the real help, for me, was several years of abstract math PROOF courses, the ones that are usually for math majors. That is where you see proofs, written in english (or whatever, but not foolish symbols/code), in set theory, group theory, graph theory, measure theory, and so on. It is where you deal with the first examples of complexity ("is a countable infinite set, such as the integers, the same size as an uncountable infinite set, such as the real numbers? Proof that no one-to-one mapping exists between the two."), transformation of a problem into a smaller or already-solved problem ("... which reduces to the lemma we already know is true, so we know the problem we're trying to solve is proven, also.")

The years of work with this, build some basic intuition and also give you useful tools.

I was given a nasty programming task, one that looked like weeks of work on an ill-specified set of requirements that were guaranteed to change. Worse, it was a financial application in which a mistake could result in lawsuits. (There was a guarantee that, post-implementation, the customer would change the requirements.)

How to do this, without truly shoddy, bug-ridden code? It turns out that all of their "special case" requirements could be translated to a problem dealing with equivalence classes in sets, and the robustness of the solution could be traced to the robustness of the translation of the problem. A proof in one area translated to a correctness assertion in the design for the code. Implementing the code itself was an hour using a simple table-driven code, easing maintenance.

When they changed the requirements post-installation, with more special cases, the engineer installing the code needed to add a couple of entries to a table and restart the application. He charged them a lot of money to do it, too. :-)

Jeff Bowles on April 2, 2009 8:25 AM

Math skills are usually an interface problem.

In China, they're taught symbols as concepts early. In the USA, Europe and other English speaking countries, this doesn't happen until far later (usually in math class) and it's a big leap.

How hard would the concept behind a summation symbol be to you if it had been first introduced to it at the age of 6?

Frankly, most math concepts are, in and of themselves, pretty trivial. The barrier to entry is all those pretty greek symbols with meaningful spatial positioning. If you're not taught to think with symbols early, you probably never will.

ThatGuyInTheBack on April 2, 2009 8:39 AM

> Note that he specifically says native tongue, not English. Which makes me wonder why all of Dijkstra's most important writings were in English, not his native Dutch.

In fact, Dijkstra's essay about semaphores was written in Dutch.

http://www.cs.utexas.edu/users/EWD/transcriptions/EWD00xx/EWD74.html

Reference: Wikipedia article on semaphores,

http://en.wikipedia.org/wiki/Semaphore_(programming)

JMW on April 2, 2009 9:00 AM

"They teach math all wrong in school. Way, WAY wrong."

Yes, in American schools they certainly do, but it's typical of an "ugly American" to assume that whatever is done in the US is done world wide.

I moved to the States from Germany in my teens and started 9th grade here. At first I thought they were kidding when the math teachers expected me to memorize formulas to apply to math problems. Sadly enough, that is apparently the norm in schools here. Instead of teaching kids how to logically analyze a problem, they teach kids to memorize formulas. No wonder our kids suck at math!

I've always been good at math, as long as I can remember, and I believe it does help me with programming. However, maybe logical thinking and problem solving analysis are the important parts that apply to programming.

Dennis on April 2, 2009 9:17 AM

Programmers should understand discrete math really well because you're always dealing with sets, functions (domains and ranges), and relations whether you like it or not.

Steve Goguen on April 2, 2009 9:40 AM

Hmm. I got my first degree in Fine Art, then took up programming. Always saw it as an entirely creative/artistic process, just a different bag of brushes. I'm old enough to have programmed in assembler 'cus no-one told me it was hard. Along the way I picked up Maths (note, the 's' on the end, it is short for Mathematics. Math is, well, just short.) Enough to get a second degree in it anyway, but that was just for fun. 25 years on and several hundreds of million of dollars of development spend later, I still see it as a creative/artistic process but with an even bigger bag of brushes.

Ashley Kitson on April 2, 2009 9:41 AM

I agree with Dijistra... and a lot of people that has given specific examples of math being used... but I still feel a canonical example is missing.

Set Theory.

If you have write a SQL data manipulation statement, then the better that you are at math set theory, the better you will manage databases. Otherwise, go back to cursors and treat your data server as a glorified dBase storage... or google about it.

Jorge Varas on April 2, 2009 9:52 AM

Math has been marginally useful to me in my career (understanding how good statistics work can help; big-O is a lot easier once you understand series) but I believe having been a physicist in a past life makes me a much better programmer. The experimental method makes you a better debugger, and in general a healthy dose of skepticism is a programmer's best asset.

Bertrand Le Roy on April 2, 2009 10:49 AM


The first person who can lucidly explain Reed-Solomon encoding using just their high-school math and a bit of stuff they picked up because they needed it wins a prize.

You don't need math to write something like StackOverflow, because the clever people already provided you with all the tools and the platform.

Maybe when StackOverflow's search is as good as Google's Jeff will have made his point.

Will on April 2, 2009 12:59 PM

I'm curious if Jeff is ever embarrassed that he is always misinterpreting things and making terrible generalizations. I guess it gets all of us into an intriguing conversation, so it's not all bad.

chris on April 2, 2009 1:44 PM

The real reason I feel the best programmers have a strong mathematical foundation is because such a base is required for understanding the real performance of your code. It's difficult to optimize a method/function/routine/etc if you don't possess the skills require to analyze the running time of said algorithm. Yes, most people can figure out that a for loop is O(n) but as soon as you start talking O(n ln n) lots of people's eyes cross...

http://en.wikipedia.org/wiki/Big_O_notation

Jeremy on April 2, 2009 1:59 PM

Well.. your post don't follow from your title. It feels rather like something "Are competent programmers more likely to be 'mathematically inclined'?".

If ability of logical thinking is seen as a part of mathematics I would definitely say that it helps.

Since I work on the web side of things (for a small e-commerce company) most of the actual math works is of the 1+1 variety.. but lately some statistics have begun to creep in (which is interesting and somewhat fun).

(I also like to believe that I have a nice understanding of my native tongue (and an acceptable level of understanding of English).)

Berserk on April 2, 2009 2:05 PM

WTF? What are you talking about? programming is not about programming, but about communication skills, so please stop wasting our time and write something usefull. "How to control people?","How to humiliate your boss?" - thats the kind of programming related articles we would all need to be better programmers.

mark on April 2, 2009 2:19 PM

There's no point responding either way. This is just a traffic-building post. The smackdown approach indeed. I'm glad our academia shuns it.

Either you're mathematically trained programmer, and from your experience you think that it'd be nice for all programmers to have that training and you've sure found it useful and you've sure noticed other bad code that could be better if the guy didn't try to reinvent matrix multiplication.

Or you're not mathematically trained, and you're defending yourself because you may not have needed the training (although it begs the question that without the knowledge, how can you know what you've been missing)

pffft on April 2, 2009 2:57 PM

I had a coworker once who had a masters in math from a prestigious school. He could code for sure, but nobody else could decipher his code. It was the classic massive method sort of thing (thousands of lines). It was as if he thrived on mastering large problems. He was creating problems (large puzzles) as he was solving them.

As has been said (http://blogoscoped.com/archive/2005-08-24-n14.html), good programmers are lazy and dumb.

Brad on April 2, 2009 2:58 PM

Niyaz PK: I do not consider web development anywhere near REAL programming.

You must have missed this post: http://www.codinghorror.com/blog/archives/001216.html

Brad on April 2, 2009 3:15 PM

I had to integrate a function once when writing some AI code. There wasn't a lot of math in my part of the AI, or anything like that. The integrated function wasn't too complicated once I worked it out.

I just needed to recognize that the quantity I needed was a cumulative value of a function over time -- the area under a curve. If I didn't have exposure to calculus, I don't know how I would've recognized that fact or solved the problem.

Math is like any other systems science. Write enough code and you're going to run across it.

Trav on April 2, 2009 3:46 PM

"Math is hard, let's go shopping!" http://www.codinghorror.com/blog/archives/001172.html

Sorry, just had to. :)

Rick Brewster on April 2, 2009 3:49 PM

What about every time you've needed to figure out the big O complexity of your code?

Do you work with recursive or dynamic algorithms? What about basic data structures like trees, hashtables, and heaps? You need math to be able to understand their running time and correctness.

Certainly, someone can put together a CRUD web application without understanding any computer science or math. However, the same person might not be able to hack:
1. The basic data structures he uses.
2. The database management system his data is stored in.
3. The kernel
4. The compiler or interpreter he uses for his programming language.

All of those things I listed have components that require some understanding of CS and math to grok. Parsers in programming languages are often implemented as a dynamic algorithm for instance...

Do you really count as a programmer if you don't understand computers or algorithms, but can only "program" in a narrow domain that has no complexity?

Brendan Miller on April 2, 2009 4:10 PM

What code have I personally written where a detailed knowledge of math made your work easier? I had to fit sensor response curves into an insanely small eprom, so I had to create a multi-segmented Taylor series algorithm as a mechanism to fit the curves and develop the coefficients...just for instance. Web jockeys that are throwing textual data around might not have much math to do, but all of us scientific and engineering programmers sure do. I once spent 2 months playing with Mathmatica trying to come up with an approach to a programming problem. And what about game programmers? They eat trig for breakfast, I'd imagine.

scafativ on April 2, 2009 6:29 PM

People usually say what's important is the thought patterns math teaches. I think what they're trying to say is that what you need is good logic skills. As a commenter above notes (mistakenly thinking that this is evidence of the importance of maths) De Morgan's laws of logic are the sort of thing you'd use when refactoring.

James on April 2, 2009 9:25 PM

There is math and there is math.

In North America "math" is mostly about formulas.
In Eastern Europe "math" is mostly about reasoning and proofs, from very early (11-12 years old kids do proofs, some fairly ingenious!). Numbers are one of the things you can do proofs about.

It's a huge difference between the two views.

The german encryption machine (Enigma) was broken by a team of mathematicians. Not because they had to do heavy arithmetic (their calculations pretty much stopped at counting) but because they were used with the type of rigurous reasoning required for the task.

Rumunski Programador on April 2, 2009 10:33 PM

There is math and there is math.

In North America "math" is mostly about formulas.
In Eastern Europe "math" is mostly about reasoning and proofs, from very early (11-12 years old kids do proofs, some fairly ingenious!). Numbers are one of the things you can do proofs about.

It's a huge difference between the two views.

The german encryption machine (Enigma) was broken by a team of mathematicians. Not because they had to do heavy arithmetic (their calculations pretty much stopped at counting) but because they were used with the type of rigurous reasoning required for the task.

Rumunski Programador on April 2, 2009 10:33 PM

I forgot most of the advanced maths I learned in school, but I had to relearn some of it since I started developing my map making software: <a href="http://igorbrejc.net/kosmoshome">http://igorbrejc.net/kosmoshome</a>

Mostly trigonometry, nothing too fancy.

Igor Brejc on April 2, 2009 11:52 PM

In my experience, maths competence was a barrier. Almost fell at first hurdle: how do you make sense of a=a+1 ?

David on April 3, 2009 12:16 AM

your an idiot.. didn't bother to read the whole post either

name on April 3, 2009 1:38 AM

didn't realize it was april fools ;_;

jokes on me .. as usual

name on April 3, 2009 1:39 AM

We seem to have very different ideas of what maths is - to me Maths is a right brain activity, from final year school onwards. Aesthetics are very important for proofs - beauty is one of the key things a professional mathematician is looking for, and it's the main reason many advances are made. How the blogger you quote could imply that abstraction isn't a key part of maths I don't know.

It isn't obvious why maths is interesting or relevant - that's why a lot of people don't learn it. In my experience though, most maths is largely irrelevant for programming - worst case get the requirements documented by someone that knows the stuff. However the skills and abstraction you learn from doing high level maths are probably as useful as some of the skills you learn in a CS degree. And of course, maths is much more interesting than programming.

Andrew on April 3, 2009 2:32 AM

I think language and thinking skills are infinitely more important than math skills. Documentation and clearly written code are much more important than advanced theory and calculus.

Data Recovery Software on April 3, 2009 3:27 AM

"In my experience, maths competence was a barrier. Almost fell at first hurdle: how do you make sense of a=a+1 ?"

Just the wrong language to start with. "a := a + 1" made a lot more sense back then. ;)

Vinzent Hoefler on April 3, 2009 3:42 AM

See what happens when I go away for a week ñ Jeff posts a bizarre post like this and thereís little point responding as there are now over 200 comments.

But if you are still reading this, could you clarify what you mean by
ìOn the other hand, I have not found in practice that programmers need to be mathematically inclined to become great software developers. Quite the opposite, in fact.î

What is the opposite of the first sentence? That you need to be a great developer to be mathematically inclined, that being mathematically inclined will mean you wonít become a great developer, or that you need to not be mathematically inclined to become a great developer?

Steve W on April 3, 2009 5:03 AM

By the way, I'm surprised you didn't comment on this quote,

ìIt is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration.!î

Steve W on April 3, 2009 5:04 AM

@Steve W
"On the other hand, I have not found in practice that programmers need to be mathematically inclined to become great software developers. Quite the opposite, in fact."
"What is the opposite of the first sentence?"

Well clearly, he *has* found in practice that programmers need *not* be mathematically inclined to become great software developers.

"That you need to be a great developer to be mathematically inclined, that being mathematically inclined will mean you wonít become a great developer, or that you need to not be mathematically inclined to become a great developer?"
I believe that none of these count as a direct opposite. I'm pretty sure one's a complement, but I couldn't tell you which one without consulting a logic textbook.

Tom on April 3, 2009 5:22 AM

I think you need to understand the math behind the application domain you are working with. If you are doing google maps, graph theory is vital. If you are doing heuristic approximations you need numeric calculus. Programmers need to know boolean (binary) logic, because sometimes the abstraction leaks up ( http://www.joelonsoftware.com/articles/LeakyAbstractions.html )

Hoffmann on April 3, 2009 5:48 AM

For webprogramming you should be mathematically declined. It's sufficient to concanate strings together. All Jeff Atwood's applications is just string concatenation and some sql, and a odd bit of regular expression. Nothing wrong with that. I'm not saying I'm a tad bit better than him, actually a lot worse..

codemonkey on April 3, 2009 6:06 AM

Blah, blah, blah...higher level math = abstract non-linear thinking. It's all been covered so I won't go into it. That said...

I once changed a truly horrendous sort algorithm to a binary sort. The sort went from taking over two minutes to less than two seconds.

I think the programmer before me never got past Algebra 2.

Emily <-- not a spammer on April 3, 2009 6:41 AM

How on earth did you come by the idea that mathematics was primarily a left-brained activity? We "grok" SQL and set theory with the same bits of gray matter. Without that, a person will only ever be a cookbook programmer.

Math, music, and computing all involve making use of formal systems to express creativity. These three aptitudes are a statistical cluster.

Paul Murray on April 3, 2009 7:10 AM

Wikipedia says Knuth isn't dead. yet.

Jake McGraw on April 3, 2009 2:20 PM

I use math all the time when programming. Not really because it's math, but because it's a pattern language too. If you can relate a complex problem to a mathematical model, you often get free solutions, or at least a different perspective on it and the ability to simplify it.

Some examples:
Estimation software, just need to implement the formula, but still need to understand the guts of it.
Multilingual content synchronization without a master language. Based on set and graph theory.
Probabilistic caching strategy.

Do you really need math to be a good programmer? Certainly not, but there are some solutions you may not find by yourself.

LP on April 3, 2009 6:01 PM

My definition of math seems to be broader than yours Jeff. To me the "best part" of math is logic and "space perception". Those are definately something a programmer needs. When writing anything nontrivial, like designing the database or business logic of even a small application, the ability to visualize it all in your head is essential.

But I'm also with you on the right-side-of-the-brain argument. To be able to enjoy programming and designing programs/databases/UI's/whatever requires that one sees it as a form of art or self expression. You try to communicate with others through your creations. And that's art to me. That's why it always amazes me when I meet programmers who just don't care...

But I'm probably preaching to the choir here.

Antti K on April 4, 2009 1:54 AM

As with many such questions, the best we can really do to answer them is to carry out carefully designed studies.
But just to add some not-too substantive speculations, I think (but can't confirm, since who really understands the functioning of their own brain?) that math has helped me abstract more easily, as suggested by some previous posters. I also wasn't able to properly handle and understand recursive algorithms until I grasped proof by (weak and strong) induction. But my hunch is that beyond specific applications, knowing high level mathematics isn't hugely helpful to effective software engineering though it is certainly necessary for _computer science_.
I also think it is necessary to deflate both Jeff and Steve Yegge's overoptimism about picking up math "on the fly" as necessary. 3 cases which are unlikely to be comprehensible to 99% of programmers without quantitative backgrounds (unless they did several months or years of background study) include mathematical physics used in high-end visual effects and physics simulation (not real time physics game engines) in movies, advanced statistical algorithms and stochastic analysis, and cutting-edge image processing of the type developed mostly by mathematicians (not engineers and computer scientists) that involves high-end mathematical analysis. In fact, quantitative software developers in the finance industry have traditionally had backgrounds in quantitative disciplines like physics, financial engineering and math, not CS or SE.

Francisco on April 4, 2009 6:00 AM

While I heartily agree that it is no requirement to be skilled at math to be an competent programmer, I will submit that any able programmer has the potential to become a skilled mathematician. You did allude to this in your post. Although I agree that programming requires a good right brain this is true for mathematics, too. The great mathematicians are incredibly creative. But in the end, whether we like it or not, all programming ends up being a logic problem. And all math too. All good programmers have in common with mathematicians that they are excellent logicians.

Eric Z on April 4, 2009 12:19 PM

Dijkstra wrote in English because that's where the audience is, and knowledge of math helps understanding stuff like recursion, functions, pointer arithmetic, memory management and logic in general. Despite of what you guys might think, your math knowledge is worlds ahead of the average person.

LKM on April 5, 2009 5:12 AM

I have to say that, yes, competent programmers should be mathematically inclined. A few examples:
- Once as an exercise we had to process an array of numbers which was a stock price over time, and the program had to figure out at which time to buy one of it, then which time to sell it afterwards, to maximize profit (of course, it's not a realistic scenario since we're doing an a posteriori analysis, but bear with me here). Some people could do no better than brute force their way out by trying every possible difference that made sense, so they had O(n^2) programs, while by keeping track of the right info it is possible to do it with a simple linear scan of the array*. Then the scenario was complicated with one buy, one sell, one buy, one sell (necessarily in that order). Brute force, in O(n^4), was no longer reasonably feasible, and I was the only one who figured how to do it with a linear scan. Mathematics give you the insight that There Might Be A Better Wayô, and the tools and confidence to prove that your linear scan always gives the optimum; mathematics is not just about "how much is cos(1/det(dJ0(t,x)/dtdx))" (not a real formula), it is also demonstration theory, number theory, calculability theory, etc.
- Floating point. Don't get me started on this. Take http://stackoverflow.com/questions/717994/how-to-handle-multiplication-of-numbers-close-to-1 for $DEITY's sake. Anyone with a little knowledge of floating point limitations would have instantly known that they should store the numbers in their x-1 form, and make the product by adding the stored forms, adding on top of that the product of the stored forms if he suspects it may not always be neglectable. Someone with a good knowledge of numerical analysis ( http://en.wikipedia.org/wiki/Numerical_Analysis ) may, if he figures out the loss of precision would otherwise be catastrophic (if for instance, while the product of the stored forms are individually neglectable, their final sum may not), add extra precision by storing the numbers in their log(x) = log1p(x-1) form (log1p(a) does log(a+1), without loss of precision if a is small compared to 1) and add the stored forms, doing something equivalent to the multiplication at better precision (log(x) + log(y) = log(x*y)); or better yet, he would rewrite the abstract algorithm to get rid of these problematic computations and instead implement an equivalent algorithm that is resilient to the loss of accuracy caused by floating-point rounding.
- while control theory ( http://en.wikipedia.org/wiki/Control_theory ) is not mathematics, it is chock-full of them. If you receive data from the network and decide, depending on the amount of buffered data, to play back content more or less fast, you're creating a feedback loop, possibly without even realising it, and if you're not careful, you may end with an unstable system (in the sense that it will spontaneously oscillate)!

Programmers should not necessarily know all these mathematics, but enough knowledge to recognise when they're in one of these situations, because otherwise they will not even realise they're in a situation that require a good grasp of the mathematical concepts involved, and end up painfully rediscovering them. That is why I have issue with your "Maybe I'm a hopeless optimist, but I think most programmers are smart enough to learn whatever math they need just in time to attack the problem at hand." Even a smart programmer, if he is missing the mathematic culture necessary to recognise the hole he's digging himself in, will waste who knows how much time in that hole. This, by the way, is pretty much the same thing as the usual "how much CS is actually useful for programmers?" debate: without the traditional CS stuff, they are not going to recognise they're writing a O(2^n) algorithm or that their memory usage patterns have horrible locality.

So I think programmers should be mathematically inclined enough to recognise when they should be researching more mathematics for the task at hand, and that requires enough mathematic knowledge and good mathematic (and scientific) culture.

Pierre Lebeaupin

*you keep track of the minimum value encountered so far and its location, which you init with the value first item and 1, and of the max difference and the location of the pair that gives it, which you init with 0 and (1,1); you start from the second value; for each new value in the array, you check if it is strictly smaller than the recorded minimum, if yes you update the minimum value and its location; if not, you take the difference of the value with the recorded minimum, and compare it with the max difference recorded, if it is strictly higher, you update the max difference value and location of the pair, the latter with (location of recorded minimum, current location). Once you are done scanning the array, the result is the current state of the location of the pair.

Pierre Lebeaupin on April 5, 2009 8:44 AM

I'm pretty lucky to here another programmer talking about math like me. I always say math shouldn't be a programmers love, especially while talking about efficiency and how to solve realtime performance problems. It's always hard to tell a math-oriented programmer how to solve a problem by the "computer way" (math which is important to understand how to processor can do it, not how the mathematician does it).

Kekskiller on April 5, 2009 10:48 AM

I wish Jeff spent more time reading comments. He seems to write, maybe read a couple of the first comments once in a while, then move on. He only reads what's put into books and that's a terrible shame. So many of these comments are much more informed and therefore informative than anything he writes.

I've also noticed an increasing trend of the articles being increasinly narrow in focus and argument. I'm beginning to think that the articles are being constructed for the simple purpose of getting arguments happening, which will get more visists, more blog reactions and therefore more advertising $$. That's a shame because previous articles were more rounded.

Philip on April 5, 2009 6:27 PM

1) Big help to programmers, systems, and communications people:
combinatorial analysis, graph theory, queuing theory,

I've used Taylor & McLaurin series to deal with formulas that start with terms that almost cancel each other out. That happens a lot in dealing with error rates in long messages in communications.

Logarithms: Calculating a value on the Poisson distribution involves multiplying two factors and dividing by a third. The first can be very small. The other two can be very large. The Poisson function in MS Excel does not handle parameters that cause the small factor to be smaller than the smallest number or the large factors to be larger than the largest number. Combining the logarithms of the 3 factors makes it possible to handle vastly larger parameters.

Now if there were a way to let you use the your own VBA functions as functions in the spreadsheet....

David on April 6, 2009 3:08 PM

> I wish Jeff spent more time reading comments.

There are only so many hours in the day.. I do try to read all the comments.

Jeff Atwood on April 6, 2009 10:29 PM

"I run a small (4 people) web dev shop and I'm finding that younger coders haven't had the pleasure of writing assembler or managing without library functions."

You know, it's funny. In all this excitement on the internet lately about how good programmers don't "necessarily NEED" to go to college, and how good programmers don't "necessarily NEED" to know math, everyone forgets the importance of a college degree.

I have to take classes dedicated to assembly to get my computer engineering degree. That means I'll at least "have the pleasure" of experiencing this type of coding before I graduate, which is why my degree has this mystical "value" that nobody without one will admit.

Matt S. on April 7, 2009 7:08 AM

Two math/programming stories from the same lab:

A guy stepped into my office with a problem: the code for a 3D vision problem was slow and unreliable, and required human oversight (no pun intended). Immediately I said "there's a better way. I don't what it is, but I know it's there." Thirty seconds later I caught up to my intuition: what had been done as vector calculus could be done as group theory, fast, discrete and certain.

Some time later the same guy came to me with an optimisation problem that was eating a LOT of cycles. I came up with a method borrowed from quantum mechanics -- that's right I said quantum mechanics -- and reduced a search that had taken just over a month to a few minutes. It was the biggest optimisation I've ever done, before or since (and it was later torpedoed by the same guy, who was bucking for a promotion and didn't want any big successes in our group that didn't have his name on them).

My point is that "just in time" doesn't work. If you've thought about the math beforehand you'll see these things. If you haven't, you won't know what you're missing.


P.S.:
Dijkstra: "The use of anthropomorphic terminology when dealing with computing systems is a symptom of professional immaturity."

Maybe I'm just professionally immature, but I think that anthropomorphic terminology can be a very concise and elegant way to discuss computing systems _when_used_correctly_. It's when people don't know enough of the subject to tell a bad metaphor from a good one that things get cloudy.

Beta on April 7, 2009 10:05 AM

Back at school (tech college) my instructor mentioned that all we need to know is add, subtract, multiply, and divide. Any other formulas from there the person requesting the program would give us the formula. Granted this is a tech college where the focus is a person writing business applications, not the next Quake. But to this day the fanciest thing I had to do was a mod().

Also, I HATE MATH CLASSES to this very day.

Mike Wills on April 7, 2009 11:56 AM

@Jeff I stand corrected.

Although off topic I was trying to work out why resent posts seem so one-sided and less "rounded" and sometimes controvertial. The first through was pure advertising $$. But now I'm wondering if Jeff is moving on from being a questioning novice to owning his own opinions based on his reading and understanding. To the opinions seem "narrow" because they are a specific point of view. Regardless -reading the comments is the best way to get a broad understanding of the topics.

There was a specific question:
"What code have you personally written where a detailed knowledge of math made your work easier?"
Off the top of my head I'll list 10 that simply wouldn't have been possible without kowing mathematics. Most are a maths process so mandate mathematical understanding, but having a detailed knowledge of the underlying process meant that I could write the code in the most efficient manner.

1. Any base to Any base conversion (up to whatever base the character set can support - such as 64 (email/xml), 128, 256, or even 95,221).
2. Encryption and security (including some "hacking" - not cracking)
3. Server Performance Analytics - not "watching" numbers but performing statistical tests to determine significant changes in performance.
4. Error detection using confidence intervals (using Normal distribution through a Bayesian outlier approach).
5. "Fudged" figure detection using Benford's law.
6. Accounts Receivable collection distribution analysis for cash flow predictions and determination of collection efficiency.
7. Network throughput measurement and estimation using Poison distribution.
8. Revenue/growth prediction utilising multiple regression.
9. Rounding of generic BI graphs using pythagorean rounding.
10. SQL programming. I believe that the structure, indexing, joining and selecting in SQL requires a high level of multi-dimentional mathematical thinking. This includes both OLAP and Relational databases.

Philip on April 7, 2009 4:30 PM

I used to develop the math I needed back when I programmed for fun. Like reinventing the wheel. For instance, I used to do it with 3D software rendering for ex. Trouble was, whereas you can rotate a vertex around some point with 9 operations I did it in 12. It hadn't immediately occurred to me there was one lest simplification to be applied.

I ended up making myself look like a fool to people with inferior skills that had just been taught to mechanically apply matrices to the problem without ever bothering, or being able, to intuitively grasp what was happening and why. Whereas I hadn't even learnt of rotation matrices in school but had developed the needed math myself.

Right now I'm working on open problems and algos no one has trekked before. Again developing the math I need as I go.

Mathematical inclination and agility or intuition is the difference between a mere coder and a programmer.

You can probably train simians to code.

son on April 8, 2009 11:59 AM

When I was in High School, I was a complete art freak (painting, sketching, etc) with a passion for computer programming and absolutely no interest in Math which I subsequently dropped as a subject on.

When it came time to develop my first 3D Engine, let's just say that missing all that Math class was a bit of a bummer. I had to teach myself Trig to get the job done. Needless to say, I managed in the true spirit of Coding proving that "programmers are smart enough to learn whatever math they need just in time to attack the problem at hand".

Frank on April 9, 2009 2:40 AM

"They teach math all wrong in school. Way, WAY wrong."

This rings a bell - I wonder how much easier (or at least, interesting, and therefore motivating) it would have been if it had been anchored to reality rather than presented as a bunch of abstract problems?

BTW Right-brain/Left-brain is apparently a myth that grew up around some experiments involving people whose brains had been split in half (literally). Not did the results not apply to a normal brain, it is an example of how the popular press remains decades behind science.

Paul Coddington on April 13, 2009 11:32 PM

"I wonder how much easier (or at least, interesting, and therefore motivating) it would have been if it had been anchored to reality rather than presented as a bunch of abstract problems?"

But, to bring this back to the origional question, if someone is not interested in abstract problems, are they going to be a competent programmer?

Steve W on April 14, 2009 4:20 AM

Yes.

Preeti Edul on April 14, 2009 9:42 PM

I agree with Edul

mattbg on April 15, 2009 12:29 PM

If you look at work done over the last 300-400 years in approximating pi (for example) you will see how the idea of "creating" a working AND beautiful / elegant solution for something in maths is pretty analogous to the idea of coding.

Sure most of the work in programming is the daily bread and butter hum-drum but that work is not why people become programmers. If you LIKE (or LOVE) programming you'll quite likely LIKE or LOVE maths as well once you get beyond the simple "calculational" operations (that a decent computer program can do for you anyway because good mathematicians / programmers worked out how to en-"code" them).

Salubri on April 24, 2009 5:02 AM

Jeff, I find most of your articles shallow. This is yet another one. Its almost like u don't understand the deeper meaning of things around you. I won't add in another comment abt the specifics of this article, 'cause ppl above have just hammered you. Its amazing tht ppl still flock to read your trash.

ratz on May 27, 2009 12:05 AM

This was a good "article" if you will. I'm glad I read it.
Anyhow I have my Bachelor's & Master's in Computer Science and my MATH is horrible, but I can program very well. It all depends on the person and getting the job done in my book. I agree there are many different ways to get the job done some less/more efficient than others but at the end of the day its a matter of making the customer happy.

Aj on July 8, 2009 11:33 AM

What the hell are you all damn woodpeckers talking about?!? :))
Have you programmers never tried to read The Art of Computer Programming (TAOCP) by Donald E. Knuth.

Really... From my point of view if you manage to solve most of the exercises in that book(s) you can assume that you know the mathematical tools sometimes necessary in programming.

207BottlesOfBeerOnTheWall on July 23, 2009 5:48 AM
Content (c) 2009 Jeff Atwood. Logo image used with permission of the author. (c) 1993 Steven C. McConnell. All Rights Reserved.