Hacker News new | past | comments | ask | show | jobs | submit login
Ask HN: Is it necessary to learn maths to enter into programming?
31 points by dollarz on March 17, 2009 | hide | past | favorite | 48 comments
I'm 14yr-old-guy. (going into 15 after 2 months)

I want to learn programming, but the problem is some ppl are saying "we've to be very good in maths in order understand anything about programming and moreover, you are too young".

Is that true? I'm not that much good in maths, I know only school-level maths.

Could anyone please give me links/books to learn maths (something like learn maths for entering into programming) ? Hope you guys will understand my problem.




You don't use much of the stuff you learn in HS math in everyday programming. You don't need to understand calculus to write most programs, for example. But the underlying ideas you learn in math can make you a better programmer. E.g. the idea that the right notation can be very powerful.


PG and other posters are right that you don't really need the kind of math you learn at the upper levels of HS. What you need is this: http://en.wikipedia.org/wiki/Discrete_mathematics

Sadly, HS programs in most countries do a poor job of covering topics in discrete math, despite the fact that it is not really harder than say calculus.

When I said "need", I meant that discrete math is more applicable to programming than the other type(continous type, meaning calculus et al) of math.

You can get by with minimal knowledge in some subsets of discrete math, but some areas such as knowing simple predicate logic can be quite handy.


Also, many data analysis problems are solved best using functional style. This leads you down the right thinking path, regardless of what language you learn or use.


Its a little funny though. I learnt programming first and maths later. SO when I encountered functions in maths at school, I thought "oh I already know this stuff".


It depends on what you're working on. I do a fair amount of machine learning and couldn't get by without quite a bit of calculus, probability, combinatorics and linear algebra.


Beyond that, I think that some of the beauty of mathematics can be revealed in working on hard problems. Math just seemed kind of boring in high school because it wasn't really about understanding the way that things work. When you hit up against limitations and realize that to get your head around them there are some concepts that happen to be expressed in mathematical notation that will make you more capable, suddenly wading through a bunch of cryptic notation seems like less of a chore.

It's kind of like the difference between learning Spanish because your high school teacher told you too verses stumbling into some of Pablo Neruda's poetry and realizing that it'd be more powerful in its native form.


It helps if you are going to deal with the harder stuff. Graph Theory tends to help no end, Complexity Theory (which you should get taught in a CS class anyway) is pretty essential, as is Logic and Sets. If games interest you then you will need to understand basic physics and calculus.

Solving hard maths problems will grow the habbits needed to investigate problems when googling doesn't cut it. Infact anything that forces you to concentrate and be analytical would be good, so if you fancy studying biology then you will pick up some useful skills there.

Besides programmers tend to be better when they have interests and expertise beyond the field of computing.

You can get by with arithmetic if all you want to be is a Code Monkey / Web Developer / Java programmer. Just learn to use the tools that are given to you. But if you want to create the tools that other people use, if you want to write new code, then mathematics is going to help.

Seriously, until you know which area of computing you want to work in having the maths will offer you more options. Just remember that most of the fields of professional programming did not exist until a few years ago. When you graduate who knows what technology will be available, organic computers, optical computers, quantum computers? So learn the maths to the best of your ability and keep your options open.


"we've to be very good in maths in order understand anything about programming and moreover, you are too young"

That's nonsense!!! I started programming at age 8. I know people who started at age 4.

You DO need to know math if you want to develop software for avionics systems, robotics, or cryptography (among many others). If your interests are none of the above, all you need to learn how to program is time, passion, and dedication. It takes time and effort, not maths. OK, some basic concepts of logic are helpful, but not strictly required. Last but not least: read PG's essays on programming.


I second that. In fact, dive in now before your mind gets used to other ways of thought. Explore different schools, don't take one programming paradigm and only stick to it (e.g. don't do one of php/perl/python/javascript only till you hit your 20s.)

This is purely personal experience, but I find people who started programming early have a better "sixth sense" at getting algorithms, data structures, and design right. It's like solving crosswords, you read a description and the word/concept comes to you. Like the reverse of looking up a word in the dictionary, but with a fuzzier input! :)

I've seen late life, college usually, programmers have hour-long meetings to get to something others get in seconds.

Many, perhaps most, competitors in programming contests are 15-25. Most started programming very, very early.


Yeah - the ability to learn+adapt is more important.

So I'd say. Learn math. But maybe learn building a simple 3d game on the iPhone (maybe after Hello World though...).


It depends. :)

You don't need any in-depth knowledge that e.g. a university math student would gradually attain. On the other hand being rather good at, for example, high school math will help you understand basic concepts such as complexity (why 1000x operations is better than x^2 operations...)

Logic and logical thinking is also valuable but it can exist without much math per se. It also helps a lot to know set theory because you can think of many things in programming as sets.

On the other hand being smarter is more important than knowing math, because if you're smart you will usually pick up enough of any basic math that you need. Also, there are lots of people who like to, for some reason or another, explain and model their ideas and algorithms mostly "in math" whereas doing it "in English" would also be possible and much more comprehensible, thus removing an artificial barrier to understanding something.

However, most important of all is practising and hacking as much as you can because that's what eventually makes you smart, with regard to programming too.


You don't need math for programming web/pages or text-parsing. What you do need is a simple understanding of basic logic.

But as soon as you want to start on 2d (or 3d) graphics you'll need more math.

My tip is, learn programming first, and then use it as a vehicle to make learning math more fun. Build a simple vector graphics engine!


In high school (at least here in the USA) teachers focus on math that will help students with the natural sciences, namely calculus and a bit of statistics.

For programming, what you need to read about are Logic and Discrete Mathematics. And yes, they absolutely will help you be a good programmer.


I agree with mjgoins.

If you are motivated to do some self learning, here is a link to a course offered at UMD on Discrete structures: http://www.cs.umd.edu/class/fall2006/cmsc250/note.html

Check out the "Notes" (lecture slides), homework, quizzes, exams (all of which have the solutions posted).

Also, check out the syllabus and you can find the readings in the textbook: Discrete Mathematics with Applications by Susanna Epp. (Google Shopping: http://tinyurl.com/d99nb9)


Im a very poor mathematician and I think I am a pretty ok programmer!

The math I have ever used in programming has been minimal/low level stuff. So yes you need to be ok at maths: but only to a basic level.

At the moment I am doing a lot of work with hash algorithms and that is fairly heavy math: but still doable with some research.

I've always said that a good ability to write english (or whatever your native language is) is more important. If you are a good writer chances are you will be a good program writer too (note: not necessairily a good programmer).

A strong writing ability will let you write solid looking, readable, fluid code (which is often one of the most important things) whilst a basic mathematical grounding and some "out of the box thinking" (focus on the latter) will give you the ideas for the code to write ;D

Your never too young.


For graphics its essencial to be great in math.

Rest of programing skills lies in pattern recognition skill. Its like learning new natural language.

I would recommend You to learn esperanto (many good programmers known to me are pros in eo), latin some greek (my professors from univ told me so, i know little of them).

As previous speakers pointed out, logic is essential. I would say that logic is a base line of all success. Cooker like programmer use the tool - brain.

And good luck!


I love learning languages but I'm not convinced it's really helpful to learn if one wants to become a programmer. That said, I would recommend to the op to try and convince his parents to let him go to another country in a host family for a few months (during summer or whatever). It may or may not be useful for programming but it really broadens the mind and it's by far the easiest and most fun way to learn a language.

I would recommend to just go take a python book and start playing around with pygame... Whenever you have a problem that you don't know how to do (be it 3d or whatever), ask the question on irc (after first doing a bit of research before of course) and make sure you understand the answers given to you. You can also go and ask your math teacher when it's clearly a math problem (that's what I did when I was in High School)

By creating actual applications (start small or you will never finish) and trying to fix problems when they arise, you will learn and have more confidence in yourself.

In a few years, once you have a few games, apps under your belt, it's a great time to start learning computer science more formally and read SICP or learn algorithmics because you will have a frame of reference from your previous programing that will help you really understand the materials...

So basically the best advice is just start programing.


On this note, in addition to whatever maths/science/engineering subjects you get into, I'd recommend taking one or two modern natural/human languages - French, Spanish, Japanese, whatever (but perhaps not Esperanto because you'll get less chance to use it properly). It'll help you keep your horizons broad, while lubricating the parts of the brain that make learning languages (programming and human/natural) easier. All IMO, of course... :o)


I think you don't need to learn maths to enter into programming. I am a web developer for more than 1.5 years, and I don't need maths at all.


First of all, congratulations. The fact that you are here, asking this question, at this age, bodes well.

In terms of books/links, I'd suggest: just study your textbook. For now, try to really understand the "school maths" you are currently being taught, and do as much actual programming as you can. There will be plenty of time for more advanced mathematics in a few years.


The people you are talking to are totally wrong on the second point and neither wrong nor right on the first.

You will never be a good programmer unless you are very, very good at certain kinds of math. You can start programming if you have a fair grasp of arithmetic and know that a symbol can stand in for a number. That is, in many countries, covered in pre-algebra.

Much of the math that generally gives people trouble is not needed in the day to day lives of most professional programmers. You can also proceed quite a ways into learning foundational programming concepts (syntax, input/output, etc) before you start hitting things that will be impossible to understand without more rigorous math or formal logic.


Such as what? (honestly interested)

I would dispute the need for a good amount of logic / logical process. But I dont think that is purely about math :)


Oh wow awful freudian slip there. It should read

"I wouldn't dispute..."

sorry, busy morning ;)


Do you need to be "good at math" in the typical sense? Certainly not. Learning away certain mathematical concepts, however, helps.

To answer your question more precisely, I'll ask you a question: do you code in any high level language (Python, Ruby, Perl, PHP)? If so, chances are you're using 'associative arrays', 'dictionaries' or 'hashes'. How do they work under the cover? What is special and unique about them (A: hash tables and hashing functions).

Now, can you use the concept that's used by the hash-table primitives in your language, to sort an array of size N in a time proportion to N? What are you giving up to gain that speed advantage, how can you offset that by giving up slight speed advantage?

Now if someone is studying the same mathematical topics without having already programmed they won't have the same appreciation and attentiveness. To them "hash function" don't immediately click with programming techniques right away. Essentially my advice is start coding anyway, so the relevant topics in maths will "just click".

This is also a very different kind of math: it's largely discrete and even the continuous portions of it are elegant. This isn't sitting for hours and doing symbol manipulation or number crunching. You don't need to know what continuous and discrete mean: just pick up a discrete mathematics textbook and see how far you can work through it.

Attempt calculus, if only thing, just because the first elegant example SICP provides deals with a tiny function to compute a derivative of another function at a point.

http://funcall.blogspot.com/2009/03/not-lisp-again.html

If you decide to pursue computer science in college (which isn't strictly required if you want to program), this book may be of help:

http://en.wikipedia.org/wiki/Concrete_Mathematics

Addendum: for certain applications of programming you do need certain mathematical knowledge that goes beyond abstract concepts and notation; but even with those topics, don't let "not being good at math" deter you from trying.


I actually had the opposite experience in high school. I could program, but my math was terribly poor. My last math teacher was also a computer science teacher, so he helped me to make connections between concepts in programming and concepts in math that allowed me to grasp things I otherwise would not grasp.

So, no, you don't have to be very good at math. It can help, and is needed in certain fields, but I don't think it's needed to be a math whiz. If anything, it can help your math.


You don't need any specific mathematical knowledge, but it is vital to practice and understand mathematical thinking. Your goal should be to finish a couple of proof-heavy undergraduate theory courses, such as 400-level analysis and algebra.

Along the way you will learn lots of useful math, but that isn't the point -- other than the math you encounter in your CS classes, there is no specific mathematical knowledge required for programming. However, you need to do a lot of proofs and understand the power of mathematics, and you need to have the mathematical background to tackle whatever your specific interests turn out to be. (For instance, if you become interested in data mining, you will need to have enough mathematical maturity to study statistics by yourself, starting with any requisite calculus and linear algebra you happen to lack.)

Some people will correctly point out that you don't have to know jack about mathematics to be a good programmer. While this is true of many programmers, you sound like an especially smart kid, and you will not reach your potential without studying high-level math.


I'm not that much good in maths, I know only school-level maths.

You are fourteen years old. You probably haven't had much good math instruction yet. One of my favorite authors on school mathematics wrote, "The proper thing for a parent to say is, 'I did badly at mathematics, but I had a very bad teacher. I wish I had had a good one.'" W. W. Sawyer, Vision in Elementary Mathematics (1964), page 5. You can find a good teacher by finding good books about mathematics, even if you have never had a good teacher. Many working programmers haven't either, which is why some of them don't see the need for much math background to become a good programmer.

You are young enough to learn a lot of math and to learn a lot of programming. Learning both hand-in-hand will make you a better programmer. One good book that combines both subjects is Approaching Precalculus Mathematics Discretely by Philip G. Lewis

http://www.amazon.com/Approaching-Precalculus-Mathematics-Di...

http://mitpress.mit.edu/catalog/item/default.asp?tid=9168...

which alas appears to be out of print, but may be available as a used book or from a library. It teaches key concepts of school mathematics while also teaching functional programming with the Logo dialect of Lisp.

A great place to hang out online to learn math and programming is the Art of Problem Solving Forum, especially its subforum on computer science,

http://www.artofproblemsolving.com/Forum/index.php?f=331

which is moderated by a brilliant young man I know who is not a lot older than you are.


I'm really appalling at maths, and yet I love programming, and have been doing it full-time for over 10 years now. I came to programming very late in life, and almost had to claw my way into the industry. I was almost 30 before I even touched a PC.

There are the very odd time when I suddenly realize I need something from my school maths education (which was before 1978), and then I have to search out that stuff (e.g. geometry and trigonometry) and finally find a use for it.

I know I would be a better programmer if I understood maths better, but then I believe almost everyone would be improved by a better understanding of maths. I'm sure that studying programming will actually make some areas of maths more relevant for you.

It all depends on the kind of programming you want to do - in some areas I guess not being a mathalete might be a great hindrance.

I'm pretty sure it will be frowned upon to mention any particular language here, but Hypertalk really doesn't feel much like programming. Maybe it's because my speech patterns have actually started to resemble Hypertalk. Hypertalk lives on in http://www.runrev.com/ . (I have no connection with them other than as a user of their software.)

I wish I was in your place. I'd take every opportunity to learn maths, but I wouldn't let my maths ability/disability get in the way of my enjoyment of programming. It's a fantastic buzz, and I never grow tired of it (well, sometimes I do get a little frustrated).

I'm not sure how many people have listed any books for you, but this is the maths book I used when I followed a 1 year course in computing: http://www.amazon.com/Schaums-Outline-Discrete-Mathematics-O...


Short answer: no.

Long answer: I started programming when I was 13. I used to barely pass my maths exams. In 11th grade, we got to some basic Combinatorics, Complex Numbers, Coordinate Geometry and Advanced Algebra. Strangely enough, I got better at maths because I found these topics were relevant to programming and CompSci.

In grade 12 we got to Calculus. I couldn't figure out how it was relevant to what I was doing in my free time, and I limped along once more.

Don't worry. After you start programming, you'll come to like maths, if not love it. I have Discrete Maths in my next semester at college (the course is actually called Fundamentals of Computer Science) and I can't wait for this semester to end. I had calculus last semester, and I think I might fail (the results are not out yet).


I dont think this should dissuade you. Most of my undergraduate class are really awful at math (having had to take university level calc 1 and 2 several times each), however they are effective programmers.

There are certain things you won't be good at, though. Like math. It will be hard to use programming to do math if you don't understand what you're trying to do. So certain things will be hard.

The trick is, the longer you program, the better you'll be able to "intuit" math. By learning programming, you develop the skills to become good at math, as long as you try hard at programming. If you want to become a 9-5 Java programmer, you probably will never have any chance at improving your math skills.

Programming isn't that hard. Not at all. I started learning younger than you.


As others have mentioned, you don't strictly need that much maths to be a programmer - and almost none for web development, for instance. It does depend a lot on what you do.

I'm an interactive designer, and certainly not a good mathematician (not to mention truly awful at mental arithmetic), but the maths I use mostly - trigonometry, vectors, matrices, some basic calculus - I mostly picked up while I was working on things.

There are things I wish I knew a bit more about no doubt, but considering I left school at 16 with a C in maths, I think I've managed pretty well so far!


This has been said already, but I"ll say it again; the maths you need are concepts like symbol manipulation, logic. Beyond that the only math you need to know is related to the problem you're trying to solve with a program.

I'm currently trying to learn a new-to-me language (clojure) and I'm finding working my way through project euler (http://projecteuler.net/) to be very helpful. It might also help you with math ;)


Don't worry, you will not need them at the begining. When you find some problem where you need maths just learn about it (the wikipedia is nice place to start). The problem is to identificate which maths fields you need to solve de problem. I think that programing is a good motivation to study maths, for example I didn't care about graph teoric, trees or logic until I found that they are a great tools to solve problems. Just learn maths by programming.


No you do not need to learn mathematics, just like you do not need to do anything to 'get by'. But I recomend not satisfying with just 'getting by'. Try your hardest to learn everything which can increase your skill set and it will help in aspects of your programming. I have not benefitted from a well grounded education in mathematics but I constantly have to retrofit my knowledge, you have the opportunity to start from a good base.


You do not have to learn maths unless you are going to start writing complex algorithms for encryption and other complex calculation may be like data mining and so on. At your age you should start by writing simple scripts and read books to understand the concepts. Pick one language and learn it. I am sure when you start learning let us say, Ruby or Python you will notice they hardly go over mathematical concepts.


Learn C to start with...not ruby or python


That seems a very heavy intro to the world of programming :)


Math is important, but not the main thing in programming. If by "good at math" you mean "I can get perfect score on my exams", well then, i suck! Number crunching is what computers are for, high school math treats you like a computer, don't ever let them convince you that math is about solving equations on paper.


The younger you are when you first start programming, the better a programmer you'll end up being. Don't let anyone tell you you're too young.

You'll have to learn math /eventually/, but you don't need it yet. You can afford to focus on pure programming, and wait five years on the math.


Programming itself doesn't require math besides the very basics, however the problem domain of your programs might require more advanced math.

And it's never too young to learn programming. I know some people would consider 14 years old a late start.


Programming is one of the most difficult branches of applied mathematics; - Dijkstra

While I fully agree with the above, and I am a good programmer, good at proving theorems, I am terrible at algebra, I can barely do my taxes.


Just start with building something small. And learn math along on a need to know basis for a start, so that you don't get swarmed.

And maybe start with a language like Python. In my opinion its simple and lacks syntactic cruft.


Everyone knows math. The more math you know, the better a programmer you will be.

That said, there are more important things to programming than math. The very first of these is practice, as with anything.


Stydy math while you are young. Just in case. After 30 math is hard to grasp.


You will need math unless you want to spend the rest of your life as a second-class programmer. You don't have to wait for your teachers to "teach" you good math, you can start today by reading a good book. I recommend Peter Eccles' "Mathematical Reasoning"[1]; it will teach you how to think logically like a mathematician.

[1]http://www.amazon.com/Introduction-Mathematical-Reasoning-Pe...

Mathematics will give you a language to reason about your problems, and once you have the foundations you can start using algorithmic cookbook-type solutions you find in texts for your own problems. A good grounding in Analysis, Logic, and some basic formal methods (you can ask me to explain what these are) will make you a better communicator with yourself.

Along with mathematics you should probably venture more into systems programming. There are programmers who make software for other people, and there are programmers who make software for other programmers. At the risk of sounding snobby, you can probably guess who is having more fun :-) Master your environment. Whatever computer and Operating System you use, tinker with it to no end and figure out everything about it. Systems programmers make Operating systems and compilers, linkers and loaders, debuggers and disassemblers, packet sniffers, and hardware drivers and programming languages.

Don't forget to have fun. Most people you see here are doing software for the money/independence. Nothing wrong with that. But you don't have any bills to worry about, so you can afford to actually become a HACKER (in its cool "dark shades and gelled hair" badass sense) you can start to make stuff your friends at school will go crazy over.

In addition to maths and systems programming you will also need a COMMUNITY. A bunch of hackers who you can chat with online and show your stuff to. There will be experienced members and there will be beginners, however, your community should foster free participation and mutual respect (don't go to forums where people use sexist and racist language and don't hangout with people who call you "n00b" or some such derogatory terms. Bullies are the least capable hackers, usually.)

Challenge yourself. Read books even if you can understand only the first chapter. That's usually a good sign that you will be able to understand the second chapter, if you read the first carefully and did the appropriate research. Browse wikipedia. Lookup difficult English words; not everything has to be technology related, I learned the ABCs of English at the same time I learned programming.

You will become good at what you love, so if you love hacker culture, you will become a better hacker.

Plan your weekends to have fun. Grab an assembly language text and sit by your computer to type in the examples. You might need to get an older computer and install MS DOS to read most of the cheap books; Windows assembly programming is not fun or easy, but Linux's IS (http://asm.sourceforge.net/) Nowadays, Windows is becoming a more difficult hacking platform, all the cool accessible systems programming level stuff are being done on Unix.

Discover Unix. It's a beautiful thing. It's OK to be a hacking snob, if you talk to your friends about what you can do on Unix and brag about it, you will set a standard for what's cool. You will be the trend-setter that your friends copy and if enough of them are interested in hacking you will all compete for brag rights and all will become better for it in the long term. Make something and show it to your friends, either at school or online. That will motivate you more than anything.

I know this is too long, but I had to say it. When I was your age and slightly younger, I was a child-militiaman. I carried a rifle and sat up all night for guard shift. I dug a well with my own hands. I collected wood all day and burned it in a whole to make charcoal for cooking. None of that matters now though, by the time I was 18 I was a Unix hacker; that changed my entire youth, I don't even remember being in a war-zone as a child anymore, all I remember is making my PC speaker scream with a buggy assembly language routine and waking up the whole family at 4AM :-)


Discrete math helps you think logically - i.e. how to solve problems


Yes, if aspire to be a great programmer.


The big overlap between mathematics and programming is proof by mathematical induction. The standard example in mathematics is proving that

1+2+...+n = n(n+1)/2

The proof has two parts, first is it true for small values of n, and second does truth for a large value follow from truth for all small values.

Well, 1+2+3 = 6 and 3x(3+1)/2 = 6, so small n is looking good.

What about general n? Can we get the formula for n from the formula for earlier n, perhaps n-1?

Suppose we already knew 1+2+...+(n-1) = (n-1)((n-1)+1)/2 = n(n-1)/2.

Adding n to n(n-1)/2 does indeed produce n(n+1)/2 so gives us the second part and completes the proof.

The standard example in programming is writing a fast sorting routine. Given data x1,x2,...,xn pick one item, perhaps x1, as the pivot and work through the data accumulating two lists, big and little, of data larger than and smaller than the pivot. Join the sorted versions of big and little with the pivot in between.

The algorithm works because it works for small n as special cases and works for larger n by breaking the big case into smaller subcases.

A list with only one item is inherently sorted and a list with exactly two items is easily sorted by swapping them if needed.

A list with n items gets broken into a pivot and two lists big and little. Both lists are less than n long. Even in the lopsided case that one is empty the other is only n-1 long because we have taken out the pivot. So the sorting routine is going to work because it works for smaller cases, by just the same logic that underlies mathematical induction.

School mathematics has a misleading focus on computation. University mathematics is focused on proof.

In programming we tend to keep the proofs in our heads and not write them down. The reason for this is that computers need a great deal of handholding and babysitting. A computer program is mostly made of details that spell things out for the computer in detail. These details are typically mathematically shallow. Provided we have not made any small slips with the details the program will work and obviously so.

On the other hand, interesting programs have tricky bits that are not mathematically shallow. How do you write those? You need to think like a mathematician writing a proof. You need to find bases cases and inductive steps.

Mathematics and programming are different but mutually illuminating. There is a very close connection between a mathematic proof and the explanation of why a tricky computer program works. Learning how to create mathematical proofs will help you with writing tricky programs and vice-versa.

The most important example is calculus. Many mathematics students struggle with calculus. It is a useful exercise (perhaps for 16 to 18 year olds) to write your own computer programs for numerical differentiation and for symbolic differentiation and to get the two to agree as closely as rounding error permits. Much that is obscure about calculus then becomes clear.

The overlap of mathematics and programming is very clear in formalisms such as ACL2 http://www.cs.utexas.edu/users/moore/acl2/ which use a computer programming language as a logic in which mathematical theorems are stated and proven. The ACL2 book is excellent, but alas, it assumes a university level grasp of meta-mathematics. I fear that the book the poster seeks has yet to be written. Perhaps some-one on HN will take up the challenge?




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

Search: