Tips For Mastering A Programming Language Using Spaced Repetition

Advertisement

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 Software1” by Derek Sivers and “Janki Method2” 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 Anki3, 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 coding4
Front side of flashcard (View large version5)

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 coding6
Back side of flashcard (View large version7)

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 Knowledge8” 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 card9
Front of cloze deletion card (View large version10)
Back of cloze deletion card11
Back of cloze deletion card (View large version12)

There’s even a bad-ass plugin, Image Occlusion13, 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 deck14 or Derek Sivers’ decks for Ruby15 (ZIP) and JavaScript16 (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.

(al, ml, il)

Footnotes

  1. 1 http://sivers.org/srs
  2. 2 http://www.jackkinsella.ie/2011/12/05/janki-method.html
  3. 3 http://ankisrs.net/
  4. 4 http://www.smashingmagazine.com/wp-content/uploads/2014/08/01-flashcard-front-opt.jpg
  5. 5 http://www.smashingmagazine.com/wp-content/uploads/2014/08/01-flashcard-front-opt.jpg
  6. 6 http://www.smashingmagazine.com/wp-content/uploads/2014/08/02-flashcard-back-opt.jpg
  7. 7 http://www.smashingmagazine.com/wp-content/uploads/2014/08/02-flashcard-back-opt.jpg
  8. 8 http://www.supermemo.com/articles/20rules.htm
  9. 9 http://www.smashingmagazine.com/wp-content/uploads/2014/08/03-deletioncard-front-opt.jpg
  10. 10 http://www.smashingmagazine.com/wp-content/uploads/2014/08/03-deletioncard-front-opt.jpg
  11. 11 http://www.smashingmagazine.com/wp-content/uploads/2014/08/04-deletioncard-back-opt.jpg
  12. 12 http://www.smashingmagazine.com/wp-content/uploads/2014/08/04-deletioncard-back-opt.jpg
  13. 13 https://ankiweb.net/shared/info/282798835
  14. 14 http://www.oxbridgenotes.co.uk/other/web_development_flashcards
  15. 15 http://sivers.org/file/Ruby-sivers.apkg.zip
  16. 16 http://sivers.org/file/JavaScript-sivers.apkg.zip

↑ Back to topShare on Twitter

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.

Advertising
  1. 1

    In the section about breaking down your knowledge, “What Ruby method would you use to format Jessica?” is an incredibly bad example.

    I might answer something like ‘titlecase’ or a bunch of other things, as it is not apparent that Jessica is a string that might contain whitespace. I am guessing that you wrote the article with some white-spaces in there, which where stripped out when you put it online – otherwise I don’t get the example?

    Aside from that, thanks for the tip. I’ve always been frustrated with the flash-card approach. Especially because the relation between answers and questions often is so ambiguous that you feel you’re just trying to guess what you where thinking when you (or someone else) wrote the card, rather than actually re-engineering the solution based on your learned knowledge, but maybe these guidelines will be helpful.

    • 2

      Thanks for the heads up on this one Zaki. That’s exactly right – it got messed up in the formatting of the post. It was originally ” Mattan ” when I submitted it, so the spaces would have made it more obvious.

  2. 3

    Perhaps Anki’s capabilities make it better for some topics than other apps, or the way it helps you progress is better, but the web based (w/ mobile apps) Quizlet and Studyblue seem to have much larger libraries of shared decks, at least in the subjects I study. And they seem capable enough. Users might want to check out the preexisting libraries before putting effort into creating their own.

  3. 5

    I think this is a bad approach to learn to code. Maybe in case you’re struggling with language-specific syntax this could help, but then again, so would Google or a cheatsheet. This is no exam, you CAN look into the answers.

  4. 7

    Quite interesting and useful tool. I am still not convinced that its a good idea to learn programming. Memorizing the method or operation names is a probably is bad idea and wont help in long run. I would rather start writing some small exercises and programs that use those methods. In long run you are going to use IDE and search the API for available methods. There are many libraries and third party tools need to be used depending on each project needs and you wont care if you dont remember the API.

    I guess its best to use it for language learning, I am going to try it for my spanish learning ….see how it goes. May improve my vocabulary in English with this.

    • 8

      Yeah of course you’re still going to use the documentation – but it definitely helps me remember those obscure methods I wouldn’t even have thought of otherwise. Sure, I can keep looking it up each time but it’s much easier for me to remember that you can efficiently add up all the elements in a Ruby array with inject(:+).

  5. 9

    Are there preset card groups for different topics, or is part of learning creating the cards?

  6. 11

    While I can’t vouch for it as a programming language learning tool, I have used memrise for learning Mandarin Chinese with great success. Memrise too is a web-based spaced repetition tool and they have a vast selection of computer and engineering courses:

    http://www.memrise.com/courses/english/computers-engineering/

  7. 12

    Great article.
    I also started using anki to learn vocabulary for actual languages =) but quickly realized that you can apply SRS to programming languages as well. I agree that it doesn’t make sense to just memoize random method names and what they theoretically do. Usually I use SRS like this:
    Use small code snippets / patterns to understand how to apply these. No open questions.

    i.e. Js, reduce:
    Good:
    Which value will be returned?
    [1,2,3,4,5].reduce(function(x,y){return x + y}) //15
    Bad:
    What does Array.prototype.reduce() do? Because it is an open question and will cost you some time to answer. Additionally you will be never happy with your answer because your answer will always change. For the question above there is only one possible answer, which is 15. Short and concise.

    JS, IIFE:
    Good:
    What is the name of this design pattern?
    (function(){})()
    Bad:
    What does the IIFE pattern look like? Answering this question will cost some time because usually you would use anki to quickly review cards. With no time, environment to actually write this pattern you wouldn’t have this sense of completion.

    Git, rename branch:
    Good:
    Which is the common way to rename your current branch in git?
    git branch -m
    Bad:
    Kinda bad here would be to invert the question because you can always ask what the command will do but usually I need to find for commands while I already know what I want to do but no the other way around.
    etc.

    Of course those examples are very simple but that’s the gist of it. Use small and simple examples.

  8. 14

    Btw. a good primer to start with anki would be to just add cards for concepts you just used or used in the past. It is a bad idea to learn random stacks or stuff which you feel might be important in the future. This way you will have your very own card stack. For example it doesn’t make sense to learn about bitwise operators when you don’t have a real application for them. Save your cognitive ability for the stuff that really counts (everyday work and things which you can relate to)

  9. 15

    Hi Mattan,

    Great article! I too love Spaced Repetition, but found the setup of Anki too cumbersome. Also, there are lots of pieces of knowledge that aren’t easily “testable”.

    If you have time I’d love you to try Revisy (http://www.revisy.com). I’m building it to enable quick spaced revision of any type of information and would dearly love your feedback.

    Thanks, Craig

  10. 16

    Cool article, though I could use a version for someone who’s got a little less time on his hands.

    I’m getting up at 6 A.M. with barely enough time to get ready for work and I come home at 7 P.M. and still have to cook, eat, do house work etc. “Every morning 10 Mins” sounds like not so much, but with a stuffed schedule it becomes a tough task to even get to read a tut or so a day. Last time I even got to check codecadamy was probably 2 or 3 weeks ago.

    If you’ve got an article on your fingertips that’s called “mastering a programming language the least time consuming way” make sure to let me know *LOD* – “laughing out desperately

  11. 17

    I like reading this and also I agree… Its true… Keep sharing.

  12. 18

    anki is awesome but could never replace http://supermemo.com/ ; though unfortunately not free for the newer versions (I realized you were aware with your reference)

  13. 19

    Nice and a very useful blog for me. Thanks a lot for sharing the blog.

  14. 20

    Great article. I really like reading this blog. Thanks a lot for sharing the blog. Keep sharing.

Leave a Comment

Yay! You've decided to leave a comment. That's fantastic! Please keep in mind that comments are moderated and rel="nofollow" is in use. So, please do not use a spammy keyword or a domain as your name, or else it will be deleted. Let's have a personal and meaningful conversation instead. Thanks for dropping by!

↑ Back to top