June 2015

Think Like a Programmer

TLAP CoverAre you struggling with learning how to program? Do you read code in programming books with problems, understand basic concepts like loops, "if" statements, and functions, but then freeze up when it's time to write a program all on your own? Does it seem like other programmers have some innate gift that allows them to see the way through to a solution?

I've met a lot of fledgling programmers who felt that way. In fact, I'd say that most of my students over the years began in that category. They could pass quizzes on programming syntax--show them a block of code and ask them what the output was, for example, and they would have no trouble figuring out the answer. But when they had to write a program to perform a particular task, and they weren't given the details on the program's structure, they didn't know how to do it.

Eventually I figured out what was missing. They had been taught how programs work, but they hadn't been taught to think like a programmer. They hadn't been shown the mental processes programmers employ when they figure out how a program is going to be structured, how the trickier parts of a program can be made easier, and how they get moving again when they get stuck.

With Think Like a Programmer, I'm changing all of that. Starting with the simplest sorts of programs, and progressing through a number of specific programming areas, I show how to think your way from the problem description to a work program. This isn't an ordinary programming book; C++ syntax is only covered in brief review so you'll need another source for that if you're still learning. Instead this book will show you how you can plan to solve any programming problem.

Important Note: If you are just starting out with programming, you should check out the new Think Like a Programmer: Python Edition, which has been written for beginning programmers, and will teach you common programming syntax along with the problem-solving techniques.

So if you've been able to comprehend programming syntax and feel like you're being held back by your inability to systematically work your way from a blank screen to a finished program, I hope you'll give my book a try. This book has sold ten of thousands of copies and helped people all over the world learn to program.

Real quotes from real readers:

"A book every programmer should read once."

"I wish I had had this book when I started studying computer science."

"Has helped me tremendously in my problem solving development."

"Interesting and one of the most useful in the industry."

"I love it."

"Thank you for your book! It is worth WAY more than it costs!"

"It was incredibly helpful."

Where to Buy

Think Like a Programmer is available as a book or e-book from the usual retailers including Amazon, but I would recommend buying direct from my publisher; where you buy the physical book and get a DRM-free e-book as well!


I have a series of videos on YouTube. These videos cover some of the ideas from the book in a different way, or using different examples, so whether you decide to pick up the book or not, check the videos out.

Source Code

The source code for the examples in the book is available.


Updates and clarifications are available. Note that most of these issues were resolved in the second printing.

Luhn Algorithm

If the explanation of the Luhn algorithm (not how to solve it, but the algorithm itself) isn't completely clear, I've written an expanded explanation.

Instructor's Exercise Guide

I am sometimes asked if there is a solutions manual to the chapter exercises. There is not, because the point of the exercises is how you arrive at the solution, not the solution itself. However, I've written an exercise guide for instructors. This is intended to help instructors and their lab assistants in coaching struggling students; it provides suggestions, especially for the tricker exercises, on how to assist students while still letting them find their own way as much as possible. If you are an instructor or assistant and want a copy of the guide, please contact me.

Share this

How Software Works

HSW CoverSoftware is the engine that drives our modern world, but most people have little idea how it all works. We see a "lock" icon on our browser and assume it's okay to send our credit card number across the Web—but what's really going on behind the scene? How can a high-def movie get squeezed onto a single disc or through a home network? How do searches return results instantly?

The answers to all these questions and more appear in How Software Works. This book demystifies the magic of software. Topics include:

  • How data is encrypted
  • How passwords are used and protected
  • How computer graphics are created, both in movies and in games
  • How video is compressed for streaming and storage
  • How data is searched (and found) in huge databases
  • How programs can work together on the same problem without conflict
  • How software produces directions on maps
  • How data is secured on the Web

How Software Works breaks down these processes with patient explanations and intuitive diagrams so that anyone can understand—no technical background is required, and you won't be reading through any code. In plain English, you'll examine the intricate logic behind the technologies you constantly use but never understood.

Where to Buy

How Software Works is available as a book or e-book from the usual retailers including Amazon, but I would recommend buying direct from my publisher; where you buy the physical book and get a DRM-free e-book as well!


I have a series of videos on YouTube. The videos that accompany this book will cover additional topics that relate to those covered in the book but which I wasn't able to fit in, so please check out the videos whether or not you decide to pick up the book.

Share this

Computer Science Made Simple

CSMS coverComputer science is a big subject, but this is not a big book. Computer Science Made Simple attempts to cover the breadth of the discipline but at a novice level. If you want to know how computers and software work, and what computer science is all about, this is the book for you.

This book would be great for: anyone who is considering studying computer science and wants to know exactly what he or she is getting into; anyone curious about how computers developed and where they might be going; people who want to know more about how the devices they use all the time work.

Unlike my more recent How Software Works, this book doesn't explain the details behind the software, the algorithms and ideas that make it all go. If you want to know how data is actually encrypted, or how software makes movie CGI, the other book is for you. Computer Science Made Simple is a high-level view of all the things that computers do. It's easy to read, but it's not fluff! A reader quote from Amazon explains it well:

I have read several beginner computer books lately and this is by far best of them, if this is beginner book at all! This book doesn't underestimate the intelligence of reader and doesn't "buy more pages" with nonsense. I mean, if you don't know how to move mouse or where Enter button is on keyboard, buy '-for dummies' books. But if you want to get little bit (well a lot actually) deeper than that, buy this book.

Topics include:

  • hardware
  • software
  • programming
  • networks
  • the internet
  • computer graphics
  • advanced computer concepts
  • computers in society

Where to Buy

Computer Science Made Simple is currently available as an e-book from places like Amazon. If you are interested in the book and want to help me out, please click through the link to buy on Amazon; due to the vagaries of publishing I don't receive any further royalties on sales of this book.

Share this

Things That Are Wonderful: The Pretty-Good Neighborhood Pizzeria

As I've grown older, I've started to pick up on those small things that make the world wonderful. It's easy to appreciate the big things: God, family, friends, love, kindness, and a host of other things it would diminish to lump together with "etc." But it's the small things I've learned to cherish as well. And there's no better example of a small thing to be cherished than the Pretty-Good Neighborhood Pizzeria, or PGNP.


Let me define what I mean. A PGNP is a local pizza place. If it's part of a chain, it's only a small local chain. The pizza is reliably tasty, and it's slid in and out of a big oven with a peel; it doesn't ride along a conveyor. But the pizza isn't exotic or even fancy. The atmosphere is simple and relaxed. The staff is friendly and seem to enjoy themselves. In short, this is not the pizza place you take someone you want to impress. This is where you go get pizza when you just want some good pizza. You often end up here because someone says, "Hey, let's just go to..."

I think a PGNP is the cornerstone of a good neighborhood. Do you ever wonder if you live in a real neighborhood, or just a collection of homes? Then ask yourself: where's the PGNP?

Here where I live, in "old" Hoover, Alabama, the PGNP is Salvatore's, which takes up half of a building that was once a Swensen's. (The other half is a Subway, of which we'll not speak.) At Sal's, you can eat delicious pizza by a bubbling fountain as you watch the traffic along Highway 31, which is exactly the kind of up-and-down ambience that suits a PGNP. In the Edgewood neighborhood in nearby Homewood, the PGNP is New York Pizza, where I've always enjoyed the food, even the time I took my pal Yancy when he was in a vegetarian phase and wouldn't allow meat on my half of the pizza ("the grease crosses the middle.") Even Alabama's fanciest address, Mountain Brook (the city people like Courteney Cox really mean when they say they're from Birmingham), has a fine example of a PGNP: the venerable Jim Davenport's Pizza Palace, where the crust is so thin you're probably allowed to eat it during Passover.

More recently I've discovered the joy of finding a PGNP when I am traveling. Visiting a far-way PGNP is a chance to become an honorary local. It feels great, like you've found a second home. For example, if you ever find yourself in Navarre Beach, Florida, the PGNP is the New York Pizza Depot. I highly recommend the Garlic Knots.

In Kissimmee, Florida, not too far from Disney World, a great PGNP is Broadway Pizza. When my family visited there, my wife had a migraine and didn't feel like eating much, so she ordered a salad, and barely touched that. When we were leaving, the waitress handed us a to-go box; inside was a fresh salad in kit form, everything separate to keep the ingredients crisp until the headache went away. So sweet! That's the kind of attention you get at a PGNP.

It's so easy to take the PGNP for granted. It's just pizza, and there's a million places to get a pizza these days. But a PGNP is more than pizza, it's part of the neighborhood family. When you walk through the door, you can feel the neighborhood chucking you on the shoulder and saying hello. The PGNP is an oasis of friendliness and cheer in a world grown bitter and impersonal. It's a wonderful thing.


Share this

2015 Update: Stealing Still Wrong

So Lee Siegel, writing in the New York Times, says he defaulted on his student loans. He apparently feels suckered by banks and colleges, and fully justified.

Let's start with the obvious. Stealing is wrong, and Siegel has stolen from everyone who will have to cover his defaulted debt. This basic truth seems to have escaped Siegel; one almost gets the impression he thinks the banks themselves are the victims, or perhaps the loan repayment will come out of some oily executive's cigar-and-yacht money. It's especially disturbing to me when a writer defends stealing because--hold on to your hats--people steal from writers all the time. Siegel has written some books, and I promise you, someone has stolen them, and has a list of rationalizations as long as Siegel's.

Siegel's essential complaint is the same complaint that every criminal makes: if I didn't commit my crime, I wouldn't be able to get everything I want. Nothing else he says in the article is anything more than a redressing of this complaint. E.g., if he didn't go to school at Columbia, he could have incurred a lot less debt, but then he would have to go to a much less prestigious school. Morally this is no different than saying, if I didn't steal the 75-inch television, I would have to watch a much smaller TV.

I might almost forgive Siegel for his self-serving article if he used his moral failings as a springboard to reform the system in some way. But Siegel seems to be a committed statist. The underlying problem is that government underwriting of student loans has allowed loans to greatly increase, which in turn has fueled the explosion in tuition. The solution is simple--get the government out of the student loan business. That's it. Siegel has it backwards, though. He hopes that massive defaults would lead to more government involvement, as though doubling the dose of poison turns it into a cure.

He writes: "Instead of guaranteeing loans, the government would have to guarantee a college education." Does he mean the government would just pay everyone's tuition? Why wouldn't he expect that to raise tuition levels even further?

Ah, but then the students wouldn't be the ones paying, would they? It would be the rest of us, the taxpayers. In other words, instead of him being the sucker, he'd like to make all of us suckers. No thanks.

In one respect, though, Siegel and I are in agreement. If this is what a Columbia education produced, whatever he paid them was too much.

Share this

Map App Detective: A Game for the Internet Age

I don't know about anyone else, but I find mapping software like Google Map, Bing Maps, etc., absolutely fascinating. Seeing locations from the air you've only seen from the ground allows for some interesting discoveries, and can make the world seem smaller. Probably because of that, I came up with a game to challenge my map app skills.

To play, you have to start with a television show or movie with an exterior scene shot on location. To make this fair, this location has to be in a locale other than the one where you live. Then, using clues in the show and the assistance of a map app, you find exactly where a particular shot was taken. For extra challenge, use a classic show instead of a current one.

Here's an example from Adam-12. This is from Season 4, Episode 13, "Pick-Up." Officers Malloy and Reed are behind a red Porsche when the driver pulls over and dumps a girl on the shoulder, then takes off. Reed stays with the girl while Malloy takes off after the car, which eventually parks:


So where exactly was this shot taken? On the curb, we see the number 8601, and when Malloy calls in, he says the car pulled into 8601 Royal Oaks Drive. But the street name, at least, is fake. To find the real address, we need to back up. Just before the girl is thrown out of the car, Reed calls in their location as westbound on Mulholland Drive. This is a well-known road in LA, and in this case they aren't kidding with the address.

When Malloy takes off, he loses the Porsche "near the intersection of Royal Oaks and Mulholland." Again, there's no Royal Oaks that intersects Mulholland, but we see Malloy leaving a hilly, barren stretch of Mulholland to where houses pop up again. Look at an aerial view, we see several places this could be. But here's the first intersection:


As an aside, because of MASH, all television shots of low California hills covered in scraggly brush makes me think, "Korea." Anyway, Malloy is emerging from the hills with a big left turn and there's a short guardrail. That puts him here, just west of Laurel Canyon Park:


Malloy turns off on a side street. Then we see this shot:


That gives us another house number, 8374, and 8374 Mulholland is right after where I showed Adam-12 on the previous image. So we're on the right track. Malloy turns down a side street, then we cut back to Reed with the girl. When we come back to Malloy he's here:


He pulls up to the stop sign, looks across the street, and that's when we get the shot of the Porsche in the carport seen at the start of this article. I had to assume this was all filmed in the same neighborhood, because otherwise I had nothing. I looked at streets in the area; I knew Malloy was looking across the street from the upstroke of a T intersection, so I looked at T intersections and tried to find that white house in the previous shot. The other clue from the shot of the Porsche is that there doesn't seem to be another house to the immediate left of the house with the carport, and we can see hills behind. Found it!


The green dot is Adam-12's location, pointed north, and the red dot is the Porsche. I would have found this faster but the problem is that the show cheated. In this shot, Malloy is actually driving back from a dead-end; but this means he would have already spotted the Porsche before he turned up the street.

Anyway, as you can see, there's some kind of drainage pond to the west of the house with the Porsche, which is why the house has no left-side neighbor. And the 8601 on the curb is not fake; it's 8601 Edwin Drive. From Google Maps street view, I can see that the carport is now an enclosed garage, so we have no way of knowing whether the Porsche is still there. (Yes, I am joking.)

So if you like map apps, are dedicated and a little bit odd, you too can play Map App Detective. If you want a fairly easy one to get started, try figuring out in which hotel the Brady Bunch stayed during their ill-fated trip to Hawaii...


Share this

Here's to You, Bart Starr


I've been saddened to read of the ongoing health troubles for football legend Bart Starr. In the great divide of college football in Alabama, I'm an Auburn Tigers fan, but unlike some, I've never thought that rooting for one team meant rooting against the other. I mean, it's not like Venus Williams talks smack about Serena, although presumably she would like nothing than to crush her sister when they meet on the court. So there's lots of people involved with U of Alabama football that I greatly admire (at the top of the list is Gene Stallings, one of the last coaches who dressed like a man who took his job seriously. Bill Belichick, please take notes.)

On several occasions, I've run into Starr at the local Taco Bell, which saddens me. Don't get me wrong, I'm not knocking Taco Bell. After all, I eat there, too. But then, I'm not a two-time Super Bowl MVP. I'd like to think that when Bart Starr is sitting on his couch and gets a craving for some Tex-Mex, he could just clap his hands and announce, "Fajitas!", at which point someone in an impeccable white chef's coat would start grinding some pepper on a skirt steak. Instead Starr is schlepping off for a Nachos Bel Grande like the rest of us.

I've also run into him at Panera Bread, but somehow that's not the same.

Anyway, even though I've stood right behind him at the drink fountain several times, I've never said anything to him, partly because I figure he's had his fill of random people saying hello, and partly because it would feel awkward to begin the conversation with anything other than, "Roll Tide," which I don't know that I could deliver with full conviction. And now when I can't expect to see him at the Taco Bell again any time soon, I'm sad because of something I've often wanted to tell him, which is: thanks.

Thanks, because when I was a boy, Starr's book Quarterbacking provided my first real instruction in football. Let's face it, football is a complicated game, and like many young fans, I understood most of the rules, but couldn't perceive the high-speed chess match that takes place during a play. Despite the name, Starr's book was about far more than his position. It introduced me to the world of football strategy, offensive and defensive alignments, player responsibilities, reads and keys, route trees, the whole thing. I started seeing the game in a different light after reading that book, and I'm not sure I would still be a football fan today if Starr hadn't revealed the depth of the game.

Others may think of Starr as a great quarterback, a class act, and a guy with one of the coolest names ever, and rightly so. But let it also be said he's been a fine teacher and ambassador of the game. So here's to you, Mr. Starr. Get well soon.

Share this