April 1, 2009
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:
- 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.
- 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.
- 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.
- 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.
- 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
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!
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.
[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.
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.
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.
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.
# 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.
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.
So, I need to know:
1) Programming wizardry
2) Hardware mumbo-jumbo
3) Software Engineering alien language
4) Network voodoo
5) Math magic?
Seriously now, you are asking too much of me.
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.
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 :)
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.
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.
oh and I did write the software in FORTRAN
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.
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).
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.
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.
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...
Boy did I feel stupid. At least I got it working, eh?
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.
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.
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.)
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.
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. ....
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.
uh, wasn't the calculus localised - germanys leibnitz vs. britains newton?
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.
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.
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:
for a bit of information on the linkage between Boolean algebra and computers.
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:).
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.
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.
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.
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.
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).
not math but logic is the key.
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.
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).
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.
@Niyaz PK: But I do not consider web development anywhere near REAL programming.
That's just discrimination.
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 :)
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.
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.
Basically, good knowledge of math will allow developers to better optimize their code, this is quite important I might say...
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.
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.
Whats this correct way of learning math then? a blogpost on that would be useful?
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 ;)
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.
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.
Personally I don't trust a programmer that is a lousy chef.
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.
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.
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.
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.
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.
Apologies for double-posting, but I had another thought: don't confuse mathematics with arithmetic.
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.
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.
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.
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.
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.
I'll second word problems and knowing enough to know where to look.
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.
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. :-)
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 :) )
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.î
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.
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.
P.S.: I bet that you use a lot of set theory when you're writing Stack Overflow.
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...
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.
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.
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!
Anyone who programmed Scheme or StandardML programming IS a type of applied math. A least for discrete values of math so to speak ;-)
Math is hard. Let's go shopping!
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.
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 emdo/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 emcan/em be both. The golden ratio is an incredibly important artistic notion, but has its basis in math. Just like emall/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 emmathematically based constructs/em: when you grok the mathematical and syntactical structure of a language, emthen/em you can start to be a artist. Not before.
So I would say that Dijkstra is correct.
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.
iTo 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.
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.
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.
Someone needs to define what good at actually means. Most people use it in a relative/subjective sense, often comparing themselves against someone else.
I use it sometimes for defining sophisticated logical expressions. In this level, mathematical logic really does the job.
I'm a CS major. More than half my classes are math. I hate math. Someone please help me.
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.
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.
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.
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!
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'.
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.
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.
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.).
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.
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.
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.
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.
Jeff, how were your math marks? =)
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.