← articles

Beware of programming puzzles

October 4, 2020

The most common piece of advice you'll receive if you want to learn programming is that you should do programming to learn it. While this is well-meaning advice, since doing programming is better than reading about it, it's incomplete.

Following this incomplete advice alone can prevent you from falling in love with programming. One of the worst implementations of this advice is learning programming by solving programming riddles.

Problems with puzzles

There are many problems with solving riddles, but let's start with isolation. They are isolated from the real world, so once you complete them, you're done with them. They never change. Real-world software does not behave like this. Real-world software has to deal with the only real constant — change. How adaptable your software is to change will tell you how well you're programming. You don't get this feedback by solving puzzles. Change is a great teacher, and it will teach you about the importance of tests early. Riddles can't teach you that.

The next problem with riddles is that they are too focused on algorithms. Unless you plan to work on algorithm-heavy products like Google Search, you shouldn't focus on that. Sure, that knowledge might get handy for technical interviews with companies that emulate FAANG interview practices, but that's a topic for another article.

Another problem with solving riddles is that they give you the wrong picture of programming. Solving puzzles encourages cleverness, while code that's too clever is a smell in real-world software. If it's difficult to understand for people that have to maintain it (this includes your future self, a more forgetful individual than you might think), it's not well written. As Donald Knuth famously said, "Programs are meant to be read by humans and only incidentally for computers to execute. "Good programmers make their code as easy to understand as possible, and solving riddles discourages that. Solving puzzles encourages the most innovative hacks possible, which is excellent if you want to compete in programming competitions, but real-world software is not like that.

Solving riddles can discourage you from learning to program and falling in love with it. I haven't yet met a programmer who said that solving programming riddles made him fall in love with programming. Maybe they exist, but it's usually something else.

Importance of having a bigger goal

Solving riddles is the impulsive implementation of this incomplete advice. You are rushing to do some programming, without having a bigger goal. The problem with this is that it's not sustainable. If you don't have a bigger goal, your motivation will be shallow, and you'll be more likely to quit when things get tough. Having a bigger goal will push you through obstacles.

An excellent bigger goal is solving a problem that's currently painful for you. Your local bus has a shitty website, and you have to search like a madman to find the next bus? Scrape their data and build the one yourself, and you'll never have that problem again. You are searching for a new apartment, but you're getting tired of continually refreshing the website for ads? Build a program that does that for you.

Whatever it is, if there's a real-life problem that you would like to get rid of with some programming, that's much better than solving riddles for the sake of it. By doing this, you'll have a much better picture of what programming is and realize how useful it is.

I send a newsletter called Regular Reveries every Wednesday. It consists of four sections: this week's article, the best of what I've read in a week, a quote that resonated with me, and a question for you.

Unsubscribe anytime. By submitting your email, you agree to our privacy policy.