Or any other programming language.

Do you ever wish that you could memorize an entire programming language and all of the libraries and APIs that you use constantly? Want to become as fluent in the technical concepts and jargon as you are in your native language? Well, I can’t give you that but I can share some tips on using Anki to improve your memory for random programming factoids and trivia. Will it make you an all-powerful programming wizard? No. What it will do is help you efficiently speed up your learning. Let’s get into it.

"One of my biggest challenges is figuring out how to shoehorn my newfound knowledge into conversations." A.J. Jacobs, The Know-It-All: One Man's Humble Quest to Become the Smartest Person in the World

What is Anki?

Anki is an open-source, spaced-repetition flashcard program. It has been popular with medical students for a while and is getting pretty popular with programmers too. There are versions for your computer, phone, and tablet, and they all sync with each other via a free cloud account. The iPhone app costs $25 right now because the developers need to pay for the servers somehow and they think that the iPhone people have plenty of cash to spare. More seriously, it is a good value for an app you will use for years.

This combo of computer programs and mobile apps lets you edit or study your cards wherever it is easiest. Always having your flashcards in your pocket to review when you have a few free minutes is meant to keep it as painless as possible.

What is spaced repetition software good for?

Spaced repetition helps you keep things in your mind easily that are important but that you might not use too often. If you need to keep a bit of programming knowledge in your head but it isn’t something that you use enough to stick by itself, then spaced repetition software can make it stick with minimal effort.

How does spaced repetition work?

So once upon a time, this guy named Herman Ebbinghaus was doing science to understand how human memory works. He did this by getting subjects to remember jumbles of letters and then testing their recall after certain periods of time. He came up with a chart that looked something like this:

The point seems rather obvious at first. You forget stuff over time. Sorta no duh! But then he went and did more science and figured out how to improve the situation. He figured out that if you test the subjects and make them actively recall the information, then it improves the forgetting curve over time. Here is a graph of that to illustrate:

What this means is that testing on the material and making the subject actively recall it leads to them memorizing it for a longer time. Even better, the spacing between the tests can increase over time while retaining the same level of memorization.

That is the crucial finding behind all this research and worth repeating. It means that if you learn a new atom of information today and you are tested on it and can recall it tomorrow, then 2 days after that, then 4 days after that, then 8 days after that, etc, etc, then you will build up some really huge spaces in between how often you need to review that atom of knowledge to keep it in your head.

Two quick examples.

Do you remember the name of the scientist I mentioned earlier? Almost certainly not unless you have heard about him before! You read and comprehended what I have been writing about and could probably recite the main idea back to me, but his name… probably not. Don’t worry about it. It just shows that you are human and that you forget things.

How about the one you probably do know? What is the thing in turkey that makes you sleepy? I am not even going to write it because most of you already know it. But why? It is a patently silly thing to know unless you a turkey biologist, turkey wrangler, whatever they call themselves. The reason you know what it is called is that people bring it up every Thanksgiving to explain how tired they are after the meal (at least in my family). You have heard it enough with enough space between each repetition that it just sticks in your head. That is what we want Anki to do for our programming knowledge.

FYI if you still don’t know what I am talking about because you don’t celebrate Thanksgiving…the substance in turkey is called Tryptophan.

Back to Anki

Anyway, Anki is a spaced repetition learning program that you can easily use anywhere. Anki helps you memorize anything you learn and put in it with fairly minimal effort and that effort gets less and less over time as long as you have decent consistency. So it sounds like a good tool to help us stuff more programming knowledge in our heads so that we never need to search Stack Overflow again right? Well… sorta. Let’s explore.

How to use Anki while learning to program.

Flashcards aren’t a be-all, end-all of learning- you always need to practice what you are learning. But, having it in your head makes it easy to practice. Think of it like using flashcards to learn a language. The cards will improve your vocabulary but you still need to practice your conversational skills.

I have used Anki for years to learn code snippets, bash commands, commands for vim or nano, Rails commands, and methods on the Ruby standard library and Rails core features. I also use it for questions and answers to keep up my knowledge about Rails.

There is a lot of Rails to keep up with and I have limited time. That is very much at the core of why I use Anki. Keeping up with screencasts, weekly newsletters, and Ruby and Rails announcements is very much drinking from a firehose. You gotta cut it down to keep that precious work-life balance intact. Anki helps me learn something once and not have to learn it again in a year when I forget it.

One way to make sure that you are not wasting your time is to only make a card for something when you need to look it up; when it is already on the tip of your tongue. That way, you are keeping yourself from forgetting something that you kinda know. You will learn faster this way and keep knowledge around longer. Programming has way too many small things that aren’t worth remembering and that you should just lookup.

How to make cards.

There is a getting started guide on the web to help you through setup, adding decks, and card creation. What I want to talk about is the formulation of cards that will help you remember programming knowledge.

What I do is make a handful of basic cards for each atom of knowledge that I want to remember. They are a question on one side of the card and an answer on the other. By making many tiny cards about a tiny atom of knowledge, you are forced to consider that bit of knowledge from multiple angles. Breaking it down this way promotes understanding and that will keep it very strongly embedded in your mind.

A few examples:

For example, the rails db:migrate command is a pretty common command to run so you probably already have a good idea of how it works. So it makes a good example of how to break down a concept into tiny, digestible parts:

  • Q: What runs the rails db:migrate task?
  • A: It is a rake task (a built-in part of rails).

  • Q: What does rails db:migrate do?
  • A: The rake task uses the files in your app’s db/migrate folder to update the database’s schema

  • Q: How does rails db:migrate keep itself from running the same migration file twice?
  • A: Rails checks the schema_migrations table for the timestamps of the migration files that have already been run in the current environment.

Memory Hooks

Once you know how to make cards, you might ask yourself what is the point? Doesn’t that sound like a lot of work for just a tiny atom of knowledge? It does but there is an added benefit to memorizing something that you otherwise wouldn’t have.

This strong atom of knowledge will also serve as a memory hook that will help you memorize other related knowledge easier. We humans find it easier to learn something that is related to something we already know a bit- which is exactly what memory hooks promote. If you know a bit about something, then learning more about its closely related ideas becomes easier.

Don’t memorize everything

Once you understand memory hooks you can use Anki to learn to program more effectively and efficiently. Don’t try to memorize everything. I know that is a temptation but you will burn out quickly. Instead, you need to strategically memorize a bit in a bunch of areas so that those atoms of knowledge act as memory hooks which make picking up more in that area easier.

None of this is advocating you only exclusively use Anki to learn or that you should make it a 5 hour a week habit. More like a 5 minutes a day, 3 times a week habit. It is very easy to overdo Anki.

Don’t overdo it. You shouldn’t try to memorize every command or a little bit of syntax. The point is to learn a few key bits well. These atoms of knowledge will give you a solid kernel of command and confidence in the subject area that you can use as a jumping-off point for everything else. Programming is still mastered by practice but a few bright spots of confidence and knowledge to work from can make the practice much easier in an area that is otherwise foggy to you.

Further Reading on Memorization