

Ask HN: Are there any resources to learn how to think about programming? - physloop

I'm a college sophomore. I've taken various C++ programming classes, and I'm currently in C++ Data Structures. While my assignments have been fairly challenging, I was never really taught how to <i>think</i> about tackling programming problems. I'd write down some pseudocode, then proceed to hack code together until the program met the professor's requirements. The whole time I feel like I'm shooting fish in a barrel hoping I get something instead of coming up with a proper strategy for achieving what I want.<p>I've purchased tons of programming books, but they merely explain language syntax. I don't want to learn how to declare variables and use loops, I want to learn how to approach a difficult problem, break it down, and come up with a proper solution. I want to develop a mindset for problem solving and programming, not learn more syntax.<p>I know the only way to improve in programming is by practicing, but programming is hard to do without a proper foundation in problem solving.
======
_pius
"Structure and Interpretation of Computer Programs" (SICP) by Abelson and
Sussman is a must read.

Some other foundational texts I'd recommend:

* "How to Solve It" is a (the?) classic introduction to mathematical problem solving. <http://en.wikipedia.org/wiki/How_to_Solve_It>

* CLRS ("Introduction to Algorithms") is the classic introduction to solving problems through computation: <http://en.wikipedia.org/wiki/Introduction_to_Algorithms>

Those texts are useful for "programming in the small." [1] As you get closer
to "programming in the large" (basically putting together non-trivial software
systems), some good things to look at are:

* The "Gang of Four" book ("Design Patterns: Elements of Reusable Object-Oriented Software") introduced the idea of design patterns to software engineering and provides a useful toolbox and vocabulary for thinking and talking about putting programs together.

* Joshua Bloch's "Effective Java" is an insightful set of heuristics on writing good code. Like with Gang of Four, you can get a lot out of this book by looking past the implementation language and thinking critically about the rationale behind the prescriptions in the book. I'd also recommend Bloch's talk, "How to Design a Good API and Why it Matters" (<http://www.infoq.com/presentations/effective-api-design>).

* A recent talk I found insightful is Rich Hickey's talk, "Simple Made Easy" (<http://www.infoq.com/presentations/Simple-Made-Easy>). In this talk, Hickey makes a strong argument for simplicity in software and the ramifications for the working programmer. I'd also recommend his talk, "Hammock Driven Development."

*I would highly recommend the "Destroy All Software" screencast series by Gary Bernhardt (<https://www.destroyallsoftware.com/screencasts>). These screencasts show an experienced developer working through small programming problems in a test driven style and explaining the reasoning behind his decisions as he goes along.

[1]
[http://en.wikipedia.org/wiki/Programming_in_the_large_and_pr...](http://en.wikipedia.org/wiki/Programming_in_the_large_and_programming_in_the_small)

~~~
physloop
I just ordered "How to Solve It" and "SICP". They seem to be exactly what I'm
looking for!

The problem with CLRS is that I haven't had a discrete mathematics course yet,
so the math involved in the book is way over my head right now.

Thank you for providing all those resources. I'll definitely make sure to
check into the remaining books and lectures.

~~~
_pius
Great, I'm glad I could help!

You raise a good point about discrete math, let me add the following to my
list above:

* MIT's 6.042 ("Mathematics for Computer Science") Lecture Notes start at first principles and go on to cover relevant discrete math topics motivated by common types of computer science problems.

[http://ocw.mit.edu/courses/electrical-engineering-and-
comput...](http://ocw.mit.edu/courses/electrical-engineering-and-computer-
science/6-042j-mathematics-for-computer-science-spring-2010/readings/)

------
pwg
You might consider reading "Structure and Interpretation of Computer Programs"
(SICP) by Abelson & Sussman

At least one version available here: <http://sicpebook.wordpress.com/ebook/>

~~~
physloop
Just ordered it on Amazon! Thanks!

------
itswitch
Try solving riddles, mathematical problems, etc. That might help to get you
into the right frame of mind. Don't shoot fish in a barrel, try to think about
a problem at first. What is the problem, what are you trying to solve? Now,
think of the approaches to solving it. How do you get the answer? Then fool
around, and twiddle with things until it works. Try to separate problems into
types of problems, each type requiring a certain type of solution, and fit you
problem into these lists. Just my two cents.

~~~
physloop
Thanks for the response. What kind of mathematical problems should I be
looking for? I've taken two semesters of calculus and a semester of linear
algebra, but I don't think it's had much impact on my programming ability.

~~~
robdoherty2
Project Euler of course! <http://projecteuler.net/>

~~~
physloop
Ah, I remember solving a few of those a while ago. Unfortunately I'm not very
mathematically inclined, and some of the problems there are extremely
difficult to figure out.

------
pnr
In addition to all the wonderful resources already suggested above, you should
check out the MOOCs on Mathematical Thinking
(<https://class.coursera.org/maththink-2012-001/class/index>) and Algorithms
(<https://class.coursera.org/algs4partI-2012-001/class/index>) on Coursera.

------
MaysonL
Try "A Discipline of Programming" and "Structured Programming" by Edsger
Dijkstra (the second with co-authors C. A. R. Hoare & Ole-Johan Dahl).

Also, Project Oberon by Niklaus Wirth, for showing how it can be done well and
clearly.

SICP and How to Solve it, as others have recommended, are also great, ditto
Project Euler.

