Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Math For Programmers (steve-yegge.blogspot.com)
32 points by hhm on Dec 9, 2007 | hide | past | favorite | 13 comments


Another closely related post is Math Every Day: http://steve.yegge.googlepages.com/math-every-day

Since most here are of a programing bent Project Euler (projecteuler.net) may be of help in that quest.


In a perfect world we would get rid of the CS major entirely and teach only math. Students interested in a computer career would take a maths course with a CS focus: very hard math and then data structures & algorithms, theory of computation, and some electives. Good programming is all about good design, and the way you learn good design is from spending a lot of time thinking about really hard math.

When two programmers are skilled in mathematics, there's no disagreement on the right way to do something since they both realize there is only one right way to do something. Minimal footprint, minimal dependencies, ease of change, minimal variable names, canonical structures, efficient run times...How can people have arguments over object-oriented programming semantics? The very notion is absurd.

When math is taught well computer programming falls out of it as a corollary. Courses like operating systems and programming languages are absolutely ridiculous. A bright student can pick up all of the useful concepts in an afternoon or two. At best they're excuses to have large programming projects.

The CS curriculum as designed is little more than a vocational school, one whose difficulty is increasingly ratcheted down to get somebody, anybody, to do the work that grows each year in complexity and tedium, owing to the previous class of terrible coders it was necessary to graduate. The demands on the software haven't gotten any more taxing, the existing codebase has just managed to grow in size without any new intelligence being added to its construction.

When you think about it, the CS curriculum, its practical side anyway, is basically just a massive toolset designed to cope with the fact that its students are bad at math. Constructs like object-oriented programming, they start out with the assumption that you won't see the canonical way to do something, and then everything that follows thereafter is damage control. How to program at the lowest common denominator.

That books on design patterns exist, and are so widely celebrated, is perhaps the most damning indictment of the field I can think of. If you can look at a design pattern book and learn something, it means you are missing the strong inner core of understanding that allows another, better designer to look at the table of contents and go 'duh', and that inner core is absolutely necessary to construct any sort of code that is going to work together with other code in a completely seamless, mathematical sense.

The curriculum, and these techniques, are heavily influenced by economic forces---this is not a secret. (Programmer churn, outsourcing, the never-ending cutbacks in the cost center.) You need to have all your programmers speaking the same language, and it's a lot easier to have them speaking OO than math. And so you get a product that sucks, and we're all using an internet in 2007 that still looks like a Model T, and everyone gets excited when they can update a calendar without refreshing their browser. You've got to be kidding me.


Good programming is all about good design, and the way you learn good design is from spending a lot of time thinking about really hard math.

An interesting idea, but empirically false. Design sense is a necessary condition for being a good hacker, but not a sufficient one. As for the second half, I agree one can learn about design from studying math, but most of the people I know with a great sense of design didn't acquire it that way.

If you said "A sense of design is a big component of being a good programmer, and you can learn a lot about design by studying math," you'd be right.


You sound like someone who hasn't programmed much in a real-life scenario. Programming is far from being black and white as mathematics can be. From my own experience, programming is a mash of creative arts and psychology with a mathematics flavor . Most of the time, a programmer is just calling other people's API (which is unfortunate, in my humble opinion). So, what is the usual skill usage of a programmer?

50% Knowing the programming language you use and its libraries. 20% Communication. 10% Debugging efficiently. 10% Creativity and taste. 10% Algorithms and mathematics.

Of course, these percentages depends on what you're doing -- e.g., a programmer working on a numerical-analysis application will need mathematics much more often than the average web-developer.


I'm guessing the philosophy you're describing here is the one you subscribe to. How has it worked for you? I'm generally curious. What are your personal accomplishments that would bolster your argument that this way is the best way to learn CS?


A good post, and the comments mention some good looking books. Any other suggestions from fellow hackers for math learning books? I have perused MathWorld (http://mathworld.wolfram.com/) but it would be nice to have a book ...


I majored in Math as an undergrad and the best books by far (at least, from a Mathematician's point of view) are those in the "Springer Undergraduate Mathematics Series": http://www.springer.com/west/home/new+%26+forthcoming+titles...

All of the comments here seem to be of the form "I'd like to learn Math". However, it's a pretty huge subject! The topics to study really depend on the programming task. The best introductory book on University style Mathematics from the above range is: http://www.springer.com/west/home/math/analysis?SGWID=4-1004...

I've spent most of my years coding solver libraries in C++. I am interested mainly in solving Ordinary and Partial Differential Equations, which require a good knowledge of numerical integration techniques. The prerequesites include Real Analysis, Linear Algebra (for the matrix solvers) and Numerical Analysis, for instance.

The best way that I've found to learn a new mathematical topic (or indeed a new programming language) is to give myself a really cool project which requires knowledge of it and then figure out a solution. I used to read Math books on the bus into University, but you just don't get the same level of knowledge that you would if you were making a fun bit of software that needed it.

A great example here is to program your own 3D engine, without using a 3D API! There is no way you would be able to compete with DirectX or OpenGL for quality, but the underlying mathematical knowledge of the graphics pipeline will give you a much better understanding of how the "big" APIs work. It's also great fun too!


"The topics to study really depend on the programming task"

I agree... My day job does not involve any heavy mathematical problem solving, but a good intro to discrete or concrete mathematics (IMHO) proves to be a good foundation for programming in general.

I studied in an Indian curriculum and have had a lot of math schooling, but it was always done "wrong", with more emphasis on getting the answer right with no need to understand _why_ that answer is right, hence my reason to ask for a good book that others found an enjoyable read and one that teaches the concepts right. I always found math to be interesting, though sadly haven't done much of it since graduation...

Thanks for the link to the Springer series. I have never heard of it, but I will look into them, though honestly, the Knuth book does intrigue me. Looks like a time to hit the local bookstore...


I'm currently slowly working my way through Concrete Mathematics by Ronald L. Graham, Donald E. Knuth, and Oren Patashnik.

It's basically an expanded version of the first bit of Knuth's Art Of Computer Programming. I've found it really fascinating and a lot of fun so far even if it is a bit slow going for me.


I was browsing Amazon and I came across the same book. I think I certainly will look into this one, though some of the comments (on Amazon) made it sound like the authors jumped from one topic to another, and skirted around a lot of the in-depth discussions that you would normally expect from a book like this... Has this been your experience?


How quickly have you been able to move through Concrete Mathematics? It looks like the sort of thing you might be able to do 1-2 problems a day.


It depends on how much time you devote to it...but the nice thing about that book is that each chapter's exercises are broken up into "Warmup exercises", "Homework exercises", "Exam questions", and "Research problems". It's still well worth working through it though - the authors are shockingly competent.


Linear algebra -- matrices etc. -- is the bit of my undergrad. mathematics that I use most often in programming.

I really liked the informal text by Gilbert Strang, "Introduction to Linear Algebra". The 3rd edition is quite expensive, but Strang's video lectures are available here:

http://web.mit.edu/18.06/www/Video/video-fall-99.html

For "getting" mathematics as a way of problem-solving, I suggest Polya's books, starting with "How to Solve It".




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: