So lately I've been trying to learn to program. It's quite clear that the best way to learn will be by doing. What I find odd is the structure of programming books (or educational materials) don't support this notion. Even the most interactive resources I've found (why's Try Ruby, Eloquent Javascript, etc) follow a structure like this:
1. describe concept
2. demonstrate application (sometimes)
3. provide a related exercise (sometimes) with solution (sometimes)
A typical (basic) math book, and what I'd like to find in a programming book, goes something like this:
1. describe concept
2. demonstrate several applications
3. provide 30-50 related exercises of increasing difficulty
4. provide solutions (with explanations[1]) to most or all of the exercises
[1]Math books usually don't provide explanations, but I think they would be helpful in a programming book.
It may not be pretty, and math books often use terrible exercises (especially the "real-world" exercises), but if you sit down and work through all of them, you will learn.
Programmers often say, "Just start a project." I've found that's a good way to learn how to do a particular project, and a good way to learn how to piece together frameworks and plugins and libraries, but not necessarily a good way to learn how to program (I understand all of that is part of programming, but I think there's a self-sufficiency that I'm looking for that is separate from the piecing together of things).
At any rate, does anyone know of a resource that's closer to the math book style (preferably Ruby or JS)? Is there a reason why programming books aren't written in that format?
The Science of Programming by David Gries was very good, it covered some maths needed for programming such as set theory and then it used its own programming language (based on Dijkstra's) to discuss programming language concepts that may come up. It had a great little section about deriving conditions based on loop invariants. Also there's a section on Predicates. Basically it covers all the stuff you'll need to know when using any programming language and that programming language tutorials fail to discuss.
You can see a preview at Google Books: http://books.google.ca/books?id=vv5pot-ySsEC&lpg=PP1&...
There's also A Discipline of Programming by Dijkstra and I love that one too. He has examples of great algorithms and the way he develops them is awesome: http://www.amazon.com/Discipline-Programming-Edsger-W-Dijkst...
The reason books like that aren't written is because they're too academic for some peoples' tastes. Unfortunately, books like Head First or whatever else, sell like hot cakes because they appeal to the lowest common denominator of programmer, the one whose eyes glaze over whenever there's math involved (that's usually the North American programmer, Europeans (at least the French and Dutch) don't mind the math).
I also think a lot of people dislike books with several exercises because they add way more pages. You don't need 3-5 pages of exercises, older math books only had 0.5-2 pages of exercises. Older math books are also not cluttered like the modern textbooks.
You could also do what Dijkstra did, which was write. Think and write about your experience, think and write about how you will approach a problem and explore alternative solutions, etc. Make up your own little notation for programming so you can free yourself from worrying about some obscure syntax or library call in a language.