« Scala for C# programmers, part 6: infix operators | Main | Faster development through less crap »

## April 02, 2009

### Mathematics and programming

Jeff Atwood disputes the theory that competent programmers should be mathematically inclined. His conclusion may or may not be correct – I don’t have any evidence one way or the other. His reasoning, however, is wrong.

Jeff observes that “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 gives the example i = j++ / (x + v) -- “not,” he rightly observes, “exactly the stuff mathletes are made of.”

Right, and *nothing to do with being mathematically inclined either*. Jeff seems to be one of those people who believes that what mathematicians do is sit around doing ever harder calculations. The sort of people who can only imagine Andrew Wiles proved Fermat’s Last Theorem by a fiendishly complicated process of long division.

In reality, the bulk of mathematical effort goes not into performing calculations, but into hypothesising and proving general truths. Let’s take a quick run down of the kind of skills mathematicians *really* use in doing this:

- Identifying useful abstractions – separating out the salient points of a problem.
- Formulating a path from A to B – building a high-level plan of attack for a problem or proof.
- Turning that plan of attack into a series of precise and rigorous steps, expressed using an abstract and formal notation.
- Bundling up appropriate partial results into handy lemmas – another example of identifying useful abstractions.
- Thinking about special cases that might invalidate the assumptions of the proof or require special handling.

The core skills of mathematics sound awfully like the core skills of programming. It is only “very hard … to draw a direct line from ‘good at math’ to ‘good at programming’” if you confuse mathematics with “mathletics.”

April 2, 2009 in Science, Software | Permalink

## TrackBack

TrackBack URL for this entry:

https://www.typepad.com/services/trackback/6a00d8341c5c9b53ef01156ec3ed9d970c

Listed below are links to weblogs that reference Mathematics and programming:

## Comments

As you know, professor, I did the 'computation' option in the Maths degree when it was first introduced - it used a Lisp variant (some pre-Scheme thing very like Scheme) as a functional language (mostly), and covered a subset of SICP, along with some axiomatic semantics type stuff (variants, invariants, structural induction) and the Halting problem (named after the industialist and mathematician Sir Jebediah Halting) presumably on the grounds that they felt a computation course worth its name had to include it.

Anyway, I felt (and I know that the plural of anecdote is not data) that people's ability at it was unusually poorly correlated with their ability at the rest of our syllabus e.g. I was a fairly mediocre student but found it piss-easy whereas some people on the whole much better didn't 'get it' at all.

Obviously other people had their leanings (e.g. pure, applied, stats) but I think this was notable.

I don't know what, if anything, this indicates.

I do remember their being a book in the orange computer science book series round in the 80s (you remember them, there was a category theory one), to do with some sort of formal methods bollocks and it struck me that it was parody mathematics i.e. mathematics written by someone who thinks maths is like A Level maths only on a grander scale e.g. lots of 'From Lemma 237 and Lemma 239 and Rule 37 we can prove theorem 116', which just as maths isn't 'hard sums' it isn't this either.

But then, as you recall, I am convinced that the British academic Comp-Sci enthusiasm for formal methods in the 80s was essentially a scam.

Posted by: Harvey Pengwyn at Apr 3, 2009 8:38:03 AM

Agreed. To be clear, I'm not talking about mastery of mathematical computing theory (Lisp? You were lucky, lad. On my course we had to make do with Turing machines, etc. etc.) when I talk about the possible relevance of mathematical skills to programming. I'm talking about the analytical and reasoning techniques of mathematical practice, and how the equation "mathematics = rilly rilly hard sums" misses the point of what mathematics is and why it may be relevant.

Posted by: Ivan at Apr 3, 2009 9:03:08 AM

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

I thought it was odd that that article completely ignored the primary part of Dijkstra's comment - language ability, any language ability. I can remember reading somewhere that the person who wrote the first compiler was a linguist, and that makes a lot of sense to me. In my experience, the act of parsing a program uses many of the same skill sets as parsing written language.

Posted by: Stephanie at Apr 5, 2009 9:04:50 PM