Should Competent Programmers be "Mathematically Inclined"?

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 :slight_smile:

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 :wink:

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.

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.

@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.

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.

No bugs.

Maths works!