Archives

All posts for the month March, 2013

REVIEW: Think Like A Programmer
(V. Anton Spraul, No Starch Press)

Is it possible to “spoil” a technical book?  Well, if so, here’s your spoiler warning.

The most important lesson from “Think Like A Programmer” is simply this: “when faced with a problem you are unable to solve, you reduce the scope of the problem, by either adding or removing constraints, to produce a problem that you do know how to solve.”  It’s a simple concept that should be engraved on every surface a beginning programmer sees. Learning to do that is possibly the most important part of turning technical knowledge of a programming language into the ability to solve problems with that knowledge.  Every problem can be broken down into smaller pieces, and eventually you’ll get to a point where the problems are simple enough that you can solve them yourself or quickly look up a solution, and then start bolting those solutions together until you have a passable solution to the original problem.  (It may not be the most efficient or bug free code, but writing code is like all other types of writing in one fundamental respect: write something, even if it sucks. You can improve it later, but having a first approximation is the most important part of a project.)

The above quote comes from the first chapter of the book, which focuses on problem solving methodologies rather than actual code.  This was the most useful part of the book for me, not just because it laid out several simple strategies for attacking programming problems, but because it was language agnostic.  The rest of the book, unfortunately, isn’t.

The programming examples in the book are all done in C++, and while they’re usually simple enough that anyone with a basic understanding of modern object oriented programming can follow the examples in the book, being able to attack the problems in that language is a completely different matter.  I was often able to approximate the exercises in languages I am more familiar with, but in doing so, I didn’t always end up solving the same problems that the exercise was supposed to cover.

As a programmer who works mostly with web projects, I would have liked to see more variety in the languages used; it would have only added a few pages to provide code examples in javascript or python or java, in addition to C++. Only a small portion of the book deals with issues that are specific to C++.  But given Spraul’s apparent belief that “real programmers” only use C++ (he writes in the introduction that “C++ is the real deal—it’s programming without training wheels”) such a change seems unlikely.

I review for the O'Reilly Blogger Review Program

Regardless, the book is still worth a read for programmers looking to break that barrier from having learned about programming to actually being able to program something (and probably hugely useful to programmers looking to make that jump in C++), and the first chapter should be required reading for every introductory programming course.  You can buy the book from O’Reilly (and if you sign up for an account on their site first, you can get this book as part of their buy one ebook get one free offer.)