Tips For Mastering A Programming Language Using Spaced Repetition

About The Author

Mattan is co-founder and CEO of One Month, an accelerated learning startup and creators of the bestselling One Month Rails and One Month HTML. More about Mattan ↬

Email Newsletter

Weekly tips on front-end & UX.
Trusted by 200,000+ folks.

In this article, Mattan Griffel will share best practices that he has discovered from using spaced repetition to learn and master a programming language. Some great articles on this topic are already out there, including “Memorizing a Programming Language Using Spaced Repetition Software” by Derek Sivers and “Janki Method” by Jack Kinsella. But because you’re busy, he’ll quickly summarize some of the best practices that I’ve learned along the way.

Since first hearing of spaced repetition a few years back, I’ve used it for a wide range of things, from learning people’s names to memorizing poetry to increasing my retention of books.

Today, I’ll share best practices that I’ve discovered from using spaced repetition to learn and master a programming language.

Some great articles on this topic are already out there, including “Memorizing a Programming Language Using Spaced Repetition Software” by Derek Sivers and “Janki Method” by Jack Kinsella. But because you’re busy, I’ll quickly summarize some of the best practices that I’ve learned along the way.

First things first.

What Is Spaced Repetition?

Spaced repetition is a system for permanently remembering something using the minimum number of repetitions necessary. The most popular tool for this is Anki, a free desktop app that enables you to create and review digital flashcards organized by deck.

In short, whenever you want to remember something, you would create a card in Anki and review it regularly.

The cool part about Anki is that, if you do it right, you’ll need to spend only about 5 to 10 minutes a day reviewing your cards. If you do this, you’ll be able to remember way more than you ever imagined, and you’ll be much more productive.

Let’s dive into the specifics.

How To Use Anki

For anything you want to learn, create a flashcard with a front and a back. When you review a card, Anki will show you the front, hiding the answer side.

Front side of Anki flashcard on coding
Front side of flashcard (View large version)

Answer the question in your head, and then reveal the other side to see whether you got it right.

Back side of Anki flashcard on coding
Back side of flashcard (View large version)

Then, assess how easily you answered the question, and select one of four options: “again,” “hard,” “good” or “easy.” Based on your selection, Anki figures out when to show you that card again.

And, yes, you can even use images in your cards.

By now, you’re excited to get started. But before you do, let me share a few tips.

1. Break Down Your Knowledge Into The Smallest Possible Units

Though not obvious at first, there are good and bad ways to create cards. For example, here’s a bad way to write a card:

  • Front. What does Ruby’s strip method do?
  • Back. It trims spaces and blank lines from the beginning and end of a string.

Why Is This bad?

First, you probably won’t be able to remember how exactly you phrased the answer because it will have been so long ago. So, each time you answer the card, you’ll have to judge whether the way you’ve explained it corresponds to what you wrote on the back of the card.

Secondly, answers that are open-ended and that consist of more than just one or two words take longer to answer. Even if it takes only a few extra seconds, those extra seconds add up over time.

Thirdly, you wouldn’t be learning how to apply this concept. Definitions are not as practical as clear examples.

Instead, I would do this:

  • Front. What Ruby method would you use to format " Jessica "?
  • Back strip

That’s much easier.

For a great guide to formatting knowledge, check out “20 Rules of Formulating Knowledge” by Piotr Wozniak.

2. Use Cloze Deletion

Following the rule above about Ruby methods was pretty easy until someone told me that class names, module names and constants start with an uppercase letter in Ruby. So, I created the following card:

  • Front. In Ruby, which things begin with an uppercase letter? (Hint: three things)
  • Back. Class names, module names and constants

The problem is that I had to recall three things, and the question was ambiguous, so it took a long time to understand.

Then, I learned about a feature of Anki called cloze deletion.

Instead of setting a front and back of a card, you would use cloze deletion to set a block of text and then tell Anki which bits of the text to remove from the card and to test you on. It looks something like this:

  • Text. In Ruby, {{c1::class names}}, {{c2::module names}} and {{c3::constants}} start with {{c4::an uppercase letter.}}.”

This generates four cards, each of which blanks out only one of those variables.

Front of cloze deletion card
Front of cloze deletion card (View large version)
Back of cloze deletion card
Back of cloze deletion card (View large version)

There’s even a bad-ass plugin, Image Occlusion, to apply cloze deletion to images.

3. Add A Card Only After You’ve Tested It

While Anki is an incredible learning aid, it’s only one way to retain information. At the end of the day, you need to apply what you’re learning. Remembering a concept will be much easier if you have experience applying it.

If you only read about a programming concept without trying it out for yourself, then your understanding will probably be incomplete. When I think something is trivial or obvious, like where to put a space or comma, I’ll usually have a hard time remembering it when it matters. For example:

  • Front. In Ruby, create getter and setter methods for name and email.
  • Back attr_accessor :name, :email

Without actually trying this out, I might forget whether attr_accessor has a colon after it, whether it accepts strings, where the commas go, etc.

A nice side effect of this is that if you brush up on this every once in a while, you’ll sometimes find that a card is no longer accurate.

4. Save Cool Tricks And Best Practices

Always save tricks and best practices that you read about, see in a video or notice in other people’s code.

I once saw someone do a cool trick in the command line to display all of Ruby’s core methods in the interactive Ruby shell (IRB). So, I made this card:

  • Front. How do you display all of the core methods in the IRB?
  • Back Kernel:: + (Tab) + (Tab)

Doing this guarantees that your code will get better over time. Even experienced developers should look out for best practices and clever techniques. It could mean the difference between quickly remembering the name of that obscure command and hunting through StackOverflow for half an hour.

5. Practice Every Morning For About 10 Minutes

The real value comes from frequent, short practice sessions. If you take more than a few days off, then your review backlog will grow, and you’ll have trouble recalling facts that you’ve recently learned. (Don’t worry: Anki caps each deck at 60 cards, and you can adjust this number.)

I like to practice my spaced repetition in the morning on the subway. As long as I stay up to date, it usually takes around 5 to 10 minutes to finish.

One last thing. I know that some of you will ask to see my deck. I highly recommend creating your own. Sure, you could download some decks out there to get started — such as Jack Kinsella’s web development deck or Derek Sivers’ decks for Ruby (ZIP) and JavaScript (ZIP) — but your own cards will be much more personal, formatted to how you learn and recall facts. You won’t learn or remember nearly as well by using someone else’s deck.

I’m sure that my techniques will change over the next few years, so I’ll try to keep this post up to date. Have you used spaced repetition or any other techniques to master a programming language? Do you have any tips to share? Please do so in the comments below.

Further Reading

Smashing Editorial (al, ml, il, mrn)