Coding is like Basketball

Coding is like basketball. If you don’t enjoy basketball, don’t get discouraged. Coding is also like a lot of other things.

The problem is that even though basketball and coding are very similar, people approach them in very different ways. Think about the process of learning to play basketball: you don’t memorize all of the rules first and then start playing. In fact, you could play basketball for years and still not know what constitutes an illegal screen, an offensive foul, or a five-second closely-guarded violation. When you first start playing, you learn rules on a need-to-know basis. Someone puts their arm around your shoulder, takes you to the courts, and says:

Put the brown ball through the orange hoop more times than the other team.  You can’t run and hold the ball at the same time. You can’t dribble with two hands. You can’t hit the other team when they’re trying to score. Now go have fun.

Just to clarify, there are more rules. However, you’re only going to learn about them by accidentally breaking them. You play with the rules you know until you break one that you don’t know; then, you internalize that new rule and go back to playing.

Unfortunately, people don’t approach coding the same way. They’re often hesitant to get started unless they feel like they know all of the rules. Many coding courses accidentally reinforce this way of thinking by starting with “the safe and technically accurate way to in-bound the ball after a timeout” rather than telling people to “put the brown ball through the orange hoop more times than the other team”.

This is the wrong approach. Coding is just like basketball. Playing is the fun part, so you should do it until something prevents you. Working on a project stimulates more growth than up-front memorization. Start by learning the bare minimum, and then play until you start breaking rules.

Let’s pretend someone puts their arm around your shoulder, takes you to your computer (oh, look, we’re already there!), and says:

You can talk to your web browser. It will listen to everything you say. You can make web pages look exactly like you want them to look. You talk to your web browser using HTML. HTML is a language that gives structure and content to web pages. Here’s an example:

<!DOCTYPE html>
<title>Your First Court</title>
<h1>Coding is like Basketball</h1>

If you’re on a PC, open Notepad and open a blank Notepad file; if you’re on a Mac, open TextEdit, go to ‘Preferences’ and change the format  from ‘Rich text’ to ‘Plain text’, and then open a blank TextEdit file. Copy the code above and paste it into the file. Name the file ‘Coding.html’ and save it on your desktop. Right click on the file and open it with your web browser.

If you have any questions, or if you want to learn anything else, Google it until you find it. Now go have fun.

That’s the bare minimum for web design; now you can start playing. Put the brown ball through the orange hoop more times than the other team.


Introductory rules provide the boundaries to start developing fundamental techniques. Basketball is made up of small component parts: proper form, footwork, body control, rebounding, passing, etc. As you play, you’ll start to understand how these parts fit together. Becoming familiar with the fundamentals and practicing them consistently is the fastest way to get better.

However, when people start playing basketball they don’t want to work on the basics; they want to work on highlight plays. Instead of practicing proper form they’ll go to the court and practice difficult fade-away jump shots. This lack of technique will eventually stunt their development and discourage them.

Difficult fade-away jump shots should only come after a thorough understanding of the fundamentals—the highlights can’t come first. As you play, you need to focus your practice on the small component parts.

Coding works exactly the same way. It’s tempting to think that as soon as you begin coding you can immediately start building world-beating mobile apps. Slow down. You need an in-depth understanding of the component parts of code and a mastery of the fundamental techniques before you can move on to more advanced topics.

Logic dictates which fundamental techniques you should use. This link shows what a basketball pick and roll play looks like. In a pick and roll play, an offensive teammate sets a screen (a “pick”) for the offensive player with the basketball. This screen slows down the ball-handler’s defender, giving the offense the advantage. The ball-handler’s next move will be determined by a logic statement: IF their teammate’s defender slides over to try to help (like the defender does in the video that I linked to above), THEN they will pass the ball to the teammate that set the screen, who is now “rolling” to the basket for an unguarded shot; ELSE IF their teammate’s defender doesn’t slide over to help, THEN the ball-handler will have an unguarded shot at the basket. If the ball-handler doesn’t execute this logic properly the play will result in a turnover rather than a basket. The best basketball players are those with solid fundamentals that are able to rapidly execute the logical responses to these if/then situations.

Coding languages have literal IF/THEN statements. And luckily, the computer will always execute the logic properly. The important part, then, is making sure that the appropriate techniques are applied in the correct situations. For example, IF a new user registers for your website, THEN you need to safely encrypt and store their information in a database. You build functional programs by combining the fundamental components of code with logical operators.


The best basketball in the world doesn’t look like fundamentals and logic. It looks like art.

Modern basketball is beautiful: elite shooting has created more space on the court; the pace of play has greatly increased; ball movement and creative passing are on the rise; players are scoring more efficiently; and teams are transitioning towards a positionless and versatile style of play. It’s smooth and graceful and stunning and dramatic. And it’s all built on fundamentals and logic.

Think about the component parts of basketball—the form, footwork, passing, etc.—as musical notes or brushstrokes. Alone, they are relatively plain—boring, even. However, you can use logical operators to string them together in the same way you might string together musical notes in a melody or combine brushstrokes in a painting. Players combine the fundamentals of the sport into patterns, and it’s these patterns that we find creative and striking and beautiful.

Elite players don’t disregard the fundamentals, but they do stop thinking about them as isolated components. They think and see in patterns. Rather than having to focus on their form or their footwork, they’re able to view the entire game like a sheet of music that’s about to be played. Game-defining highlights arise from unique combinations of smaller fundamental techniques. Once players reach a certain level of mastery, creativity takes center stage.

Despite the stereotypes, coding is more art than science. Writing code for a product is more like writing a novel or a piece of music than it is like writing a research report. You don’t try to explain or document certain phenomenon. You don’t focus on new discoveries or technical breakthroughs (although that’s certainly possible). When you write code for a product, you’re creating something—something both beautiful and practical.

In the same way that elite basketball players view the game as a pattern, the best coders see their programs like works of art. They hold the entire composition in their mind, turning it over and around, playing with patterns to optimize beauty and efficiency. Their mastery of fundamental techniques and best practices allows them to focus more on the rhythm of their work than on the individual notes.


The astute reader will have realized by now that, despite the title, this essay doesn’t apply solely to basketball. Coding can be compared to almost any skill you’ve ever learned; basketball is just one example.

The process of learning starts with a basic framework of rules and limitations. It then progresses to fundamental techniques, and then to the logical combinations of those techniques. It uses those combinations to form patterns. At the highest level, learning is the creative manipulation of the patterns formed from mastered fundamental techniques.

Coding, perhaps more than any other skill, is a pure adventure in learning. Its relatively few rules and overwhelming number of fundamental techniques result in unbelievable examples of mastery. Although the foundational nature of coding might seem boring or intimidating at first, it eventually produces unprecedented freedom for creativity. These characteristics make it easy to draw parallels between coding and almost any other skill you’ve ever learned.

Go back through this essay and replace basketball with another skill of your choosing: piano, painting, writing, horseback riding, soccer, clothing design, dancing, cooking, architectural design, Formula 1 racing, or chess. The parallels with coding still stand.

This means that you have a lifetime of experience to leverage if you want to learn how to code. Intimidated by coding but enjoy dancing? Guess what—coding is like dancing. Like experimenting in the kitchen? Guess what—coding is like cooking. Are you a Formula 1 racer searching for meaning after winning on the grandest stage and looking to conquer a new skill? Same here. Guess what—coding is like Formula 1 racing.

If you’re thinking about learning how to code, I’d encourage you to go for it. It’s never too late to start. You are not “behind”. Remember, you have a lifetime of experience that you can leverage.


One thought on “Coding is like Basketball

    I particularly like the “you’re never too old to start”. That holds true throughout ones life and the TRUELY happy people just keep learning!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s