Menu Search
Jump to the content X X
Smashing Conf Barcelona

You know, we use ad-blockers as well. We gotta keep those servers running though. Did you know that we publish useful books and run friendly conferences — crafted for pros like yourself? E.g. our upcoming SmashingConf Barcelona, dedicated to smart front-end techniques and design patterns.

Tips For Mastering A Programming Language Using Spaced Repetition

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.

Further Reading on SmashingMag: Link

Some great articles on this topic are already out there, including “Memorizing a Programming Language Using Spaced Repetition Software5” by Derek Sivers and “Janki Method6” 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? Link

Spaced repetition is a system for permanently remembering something using the minimum number of repetitions necessary. The most popular tool for this is Anki7, 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 Link

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 coding8
Front side of flashcard (View large version9)

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

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 Link

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? Link

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

That’s much easier.

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

2. Use Cloze Deletion Link

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 card13
Front of cloze deletion card (View large version14)
Back of cloze deletion card15
Back of cloze deletion card (View large version16)

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

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

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 Link

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 Link

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 Ruby18 (ZIP) and JavaScript19 (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 Link

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19

↑ Back to top Tweet itShare on Facebook

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.

  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

      Mattan Griffel

      August 19, 2014 6:34 pm

      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.

    • 6

      Mattan Griffel

      August 21, 2014 12:42 pm

      Yep that’s true! Unless you forgot what the method’s called.

    • 7

      I agree that learning to code like this is a bad idea; Anki is not a learning program but a way to memorise facts. I have been a web developer for years, and coming form a graphic design background, the coding side is my least favourite part.

      I find that I understand the concepts fine, but never remember much of the syntax or even simple things. A few years ago I had an embarrassing moment where a client asked me how to write the code for a hyperlink, a damn simple hyperlink!! And I couldn’t remember.

      Using Anki to memorise code snippets, good practices and methods has sped up my coding and enabled me to build on what I understand in a faster and more productive way.

  4. 8

    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.

    • 9

      Mattan Griffel

      August 21, 2014 12:43 pm

      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. 10

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

  6. 12

    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:

  7. 13

    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:
    Which value will be returned?
    [1,2,3,4,5].reduce(function(x,y){return x + y}) //15
    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:
    What is the name of this design pattern?
    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:
    Which is the common way to rename your current branch in git?
    git branch -m
    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.

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

    • 14

      Thank you for taking the time to writing these examples!

      Thank you Mattan for writing this article!

  8. 15

    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. 16

    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 ( I’m building it to enable quick spaced revision of any type of information and would dearly love your feedback.

    Thanks, Craig

  10. 17

    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. 18

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

  12. 19

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

  13. 20

    Robert Decousta

    October 20, 2014 10:27 am

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

  14. 21

    Robert Decousta

    November 25, 2014 11:36 am

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

  15. 22

    Florence Bell

    April 24, 2015 8:23 am

    I have read this and also got many useful text. Keep sharing.

  16. 23

    Great article, thank you.

    I have always used visualisation and memory walks to memorise huge amounts of information in the past. I have found that if I get stuck on an Anki card and can never seem to get it, that combining Anki with these other techniques cracks it for me.

    Have you tried any other techniques? No one ever seems to talk about combining Anki with anything else.


↑ Back to top