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 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.
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 )
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.
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…
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.
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…
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.
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.
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.
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.
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.
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).
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…
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.
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).
Encryption and security (including some hacking - not cracking)
Server Performance Analytics - not watching numbers but performing statistical tests to determine significant changes in performance.
Error detection using confidence intervals (using Normal distribution through a Bayesian outlier approach).
Fudged figure detection using Benford’s law.
Accounts Receivable collection distribution analysis for cash flow predictions and determination of collection efficiency.
Network throughput measurement and estimation using Poison distribution.
Rounding of generic BI graphs using pythagorean rounding.
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.
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.
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.