You don't need to remember everything
MP #31: You'll remember what you use most often, and you can (usually) look up the rest.
One question I’ve been asked on a regular basis as a programming teacher and author is, “How can I possibly remember all this?!” I also see this question asked regularly in various programming forums. Recently I saw someone ask how they can possibly remember all the different things you can do with a dictionary, and the syntax for doing all those things.
The short answer is, you don’t have to remember everything! What really matters is knowing the kinds of things you can do. Knowing how to efficiently look up syntax is more important than trying to memorize everything.
There is a lot to learn
If you’re new to programming, it’s certainly true that there’s a lot to learn, and it’s quite reasonable to feel overwhelmed at times. However, much of what you learn in a first language won’t have to be relearned in a second language. For example with dictionaries, the most important thing to recognize is that they provide a way of connecting pieces of information. Every key is connected to a value, and a dictionary can contain as many key-value pairs as you need.
When you learn your first programming language, you have to learn this concept and learn the syntax for it. When you learn a second language, you’re mostly learning that language’s syntax for a structure that allows you to connect pieces of information. Each language solves problems in different ways, so there are important subtleties to learn that go beyond syntax, but you’re not learning a whole new concept.
If you understand this, you can reason about what things you’d need to be able to do with a collection of key-value pairs. You can pull out all the keys, pull out all the values, all the key-value pairs, subsets of any of these, and much more. It’s important to become familiar with the syntax for a range of these operations, and it’s really important to write and run your own code as you’re learning. But, it’s not all that important to remember all this syntax. And you certainly shouldn’t spend much time trying to memorize the syntax for all these operations.
You need to know what’s possible
It is important to know what you can do with a particular data structure. For example, you might forget how to access an individual item from a list that’s nested inside a dictionary. But you should remember that it’s possible to nest a list inside a dictionary.
You’ll almost certainly come across a situation at some point where you’ll need to associate multiple values with a single key. For example you might need to connect multiple payments with a single user, or multiple songs with a playlist. There are many ways to look up the syntax for storing multiple items with a single key, or retrieving them later. But if you don’t remember that it’s possible to do this, you’ll have a much harder time figuring out how to structure your code.
You’ll remember what you end up using most often
You don’t have to focus on trying to memorize a bunch of syntax, because you’ll end up remembering the kinds of things you use most often. If you work with core data structures such as lists and dictionaries on a daily basis, you’ll probably remember most of the syntax for working with them after your first few projects. If you tend to use pandas dataframes more often, you’ll tend to remember the syntax for working with them in the ways you use them most regularly.
Again, what’s most important is knowing what you can do with all of these structures, and knowing how to look things up efficiently when you forget, or need a feature you haven’t used before.
Caveats
There are a couple caveats to all this. First, you should use the code you’re learning about. This is especially true when you’re new to programming, or working with a new language. Most people need to use what they’re learning in order to retain the concepts, and be able to work efficiently later by looking things up. If the learning resource you’re using doesn’t give you exercises, make up your own exercises and projects that force you to write code using what you’re learning.
Second, there are some situations where memorization is important. If you’re interviewing for a job, you may well need to do some focused practice for your technical interview. A reasonable interview process will have some accommodation for letting you demonstrate your skills without requiring you to memorize everything. You might be limited in what resources you can use, or be given some reminders by the interviewer about specific syntax questions that you’d normally be able to look up. However, if you have to look up or ask about basic syntax in order to write functional code you may not do well enough to pass the screening. Also, you might not have time to complete the larger technical task that’s being evaluated if you’re getting lost in the basics.
All of this still comes down to writing the kind of code you want to be fluent with. If you’re prepping for a technical interview, practice a bunch of technical interview questions and problems. It’s probably a good idea to spend some time memorizing the most common operations in those exercises. This will let you work efficiently enough under pressure to still perform well. If you’re pursuing data science work, make sure the core of your practice centers around data science related workflows. You’ll remember what you use, and you’ll perform as you have practiced.
Conclusions
Learning to program, and learning a new language, can be quite overwhelming. This is especially true if you have a pressing reason to learn the material, such as an upcoming interview or a career transition. Having the ability to use the concepts you’ve learned, with the assistance of a reasonable variety of external resources, is far more important than being able to write large amounts of working code from memory.
Having the ability to use the concepts you’ve learned, with the assistance of a reasonable variety of external resources, is far more important than being able to write large amounts of working code from memory.
When you watch an experienced programmer write out a bunch of working code without looking anything up, keep in mind you’re probably seeing them carry out work they’ve done on a a daily basis over a period of years. Give them a task that requires them to use unfamiliar tools, and they’ll probably have to look things up just like everyone else. The key is that they’ve probably gotten good at looking things up efficiently, and they have a really strong understanding of what’s possible and how things are likely to work. And if you’re watching a presentation with live coding, remember that the presenter has almost certainly done a number of practice run-throughs, and probably has a set of notes off screen as well.
Knowing what’s possible, and having the skills to look things up efficiently will take you a long way as a programmer. Make sure that writing code to solve a variety of problems, and building projects of varying scope, form the basis of your ongoing learning journey.
If you’re not sure what to focus on, try focusing on data structures. There’s an old saying that if you choose the right data structure, everything else will fall into place. It’s largely correct, and I would venture to say that if you know your data structures well, and understand what you can do with them, you’ll remember enough to use what you’ve learned with reasonable efficiency.