Transcript for:
Efficient Techniques for Learning Programming

This is how I learned to code in Python, Javascript and C++ by spending only a few weeks on each of them. But, learning a new language was not always as easy as this. When I learnt my first programming language which was Java, I spent months watching online tutorials and following along. But when I joined Amazon, I delivered a project in Python within the first 2 weeks. I had never written a single line of code in Python before working on this project. Later when I joined Google, I used the same approach to quickly pick up C++ and be useful to my team. And I have done this over and over again to learn other languages like JavaScript, Go and Dart. But, how am I able to do all this? Did I take some magic pill that made me a Python wiz overnight? Truth be told, it’s actually very simple. For thousands of years, great civilizations and powerful leaders have tried to uncover the secrets of learning a new programming language. To find the answer, we have to go all the way back to 1945. World War 2 has just ended and after winning the war, the British want to spread English throughout the world. As you might already know, English is not exactly a very easy language to learn as a non-native speaker. So, they created this simplified version of English called Basic English. Basic English had only 850 words. For comparison, there are around 170,000 total words in English. In addition to fewer words, Basic English also had simplified grammar rules, with a focus on basic sentence structures. To popularize the language, the British used state owned radio called British Broadcasting Corporation or BBC to create a show named “English by Radio ''. This show taught Basic English vocabulary and pronunciation to non-native speakers and was a huge success. But how could just 850 words and a few basic grammar constructs help people learn English? And can we use the same principles to learn a new programming language? To answer that, we need to know a few things about how the languages exactly work. Imagine a circle that contains the top 10% most popular words among the 170,000 total words in English. This circle would contain words like I, me, you, eat, drink etc. Then we have another circle around it that contains the next 20% most popular words. This would contain words like overpaid and programmer which makes sense. And we can keep making these circles until we cover all 170,000 words. In case you are curious, the outermost circle contains words like nincompoop and teetotaler. For simplicity, let’s combine the innermost two circles together and the rest of the circles together. Now imagine that you start reading one of the best novels of our times called “Fifty Shades of Grey” which has a total of 150,000 words. What you’ll find is that roughly 80% of these 150,000 words in the book lie in the inner circle and the rest of the 20% words come from the outer circle. For those who don’t know, this is also known as Pareto principle. Pareto principle states that 20% of your effort results in 80% of your outcomes. And this powerful principle is the main idea behind the BASIC English as well as the secret to learning a new programming language really fast. I applied the same principle to learn French and now, “Je peux parler en français mais mon accent est marrant”. “Learning a new spoken language is one thing but learning a language that a computer understands is totally different”, you might say. Well, let’s try to test this hypothesis. Let’s build the same circles for the vocabulary of programming languages. What would be the top 10% most popular concepts here? I believe it would include different data types like int, float, strings or Array etc. Maybe “if else” blocks and for loops would also be part of this circle. Maybe writing functions and classes would also be here. If you move outside to the next circle, you might have concepts like polymorphism and inheritance etc. And you can keep drawing these circles until you reach the outermost circle that might have I don’t know, maybe iterators or generators. Now if you pick all the Github repos in the language of your choice, you will find that 80% of the code would be coming from the inner 20% circle. And following what we learnt from the BASIC English example, we will focus on this 20% circle first. But as we do this, we need to be careful about 2 things. Number one, this 20% circle though fairly similar might vary a little bit across different languages. For example, in Java, you might have an Arraylist and you will call it just List in Python. Or in Javascript, you might have async/await which might be very different in other languages. The point is, this top 20% circle might change depending on the language you pick. So, you would want to do your own research on the top concepts for the language of your choice. Number two, when you are trying to learn these concepts, you need to change your method of learning. If you were trying to learn a new spoken language, let’s French for example. No matter how many movies or TV series you watch in French, you will not be able to speak French unless you actually try to talk in French. In the same way, no matter how many lectures or video tutorials you watch in Javascript, you will not be able to code in Javascript unless you actually try to code in Javascript. In a video tutorial, you will usually get the code that already works and if you copy it, sure enough, it will work for you as well. But, programming is the art of breaking and fixing things. That’s why I recommend interactive learning instead of casual learning. For example, if you want to learn Python, you can go to learnpython.org and do exercises, break things and fix them as you learn new concepts. Similarly, for Javascript, you can use W3 schools. I am sure you can find this kind of platform in other languages as well. Now that you know what to learn and how to learn it, there are 2 problems left for us to solve. How to remember what we are learning and How to learn the rest of 80% concepts in the circle. To solve the first problem, we need to first understand the Ebbinghaus Forgetting curve. Herman Ebbinghaus was a German psychologist who is well known for his work on memory and learning. He conducted experiments where he would give himself some nonsense words to remember and then test himself at various intervals to see how many of these words he could remember. What he found became the backbone of how we teach kids in the modern school system. What you are seeing is the famous Ebbinghaus Forgetting curve. This graph is a classical exponential decay graph. What this means is that right after we learn something new, we start forgetting it very quickly. But this rate of forgetting slows down over time and in the end, we only retain a small fraction of what we learnt. But what if I tell you that there is a way to retain more of what we learnt. Ebbinghaus also studied the impact of revision on our retention. What he found was that if you review the concepts again, you can increase the number of words you remember in the end. And if you repeat this multiple times, your retention can keep increasing. And this is called Spaced Repetition, which many of you might have already heard about. This is the reason why if you try to learn a new language using an app like Duolingo, they keep repeating the same words again and again in the exercises. But how do we apply the spaced repetition to learning a new programming language? The answer to this question is also the answer to the second problem that we still need to solve. So, let’s quickly cover the second problem and then we will talk about the solution. The other pending problem we have is that we have still not figured out how to learn the remaining 80% of concepts. For this, we need to take a breadth first approach to our learning. What this means is that instead of taking some random long deep path from the inner circle to the outside boundary, we just keep enlarging our inner circle. In other words, we slowly keep increasing the breadth of our knowledge. The biggest advantage of doing this is that we are only learning new things that are close to what we already know and this makes learning them very easy. But how exactly do we do this? To remember more of what we have learnt so far and to learn the remaining 80% concepts, all we need to do is build projects. But not just any projects, we need projects with increasing difficulty. I will tell you which exact projects to build in a moment. But, building projects helps you in 2 ways. Number one, as you build projects, you will encounter the top 20% concepts again and again. And this will help you achieve spaced repetition. Number two, as you build projects, you will need to learn some new concepts on the go. If you choose your projects carefully and slowly increase the difficulty, you can constantly expand your inner circle to become the same size as the outer circle. One thing that you should be aware of though is that you will never be able to learn 100% of what there is to learn. But look at you. You don’t know everything about the language that you speak and you are doing just fine. So, don’t obsess over learning everything. As I mentioned, choosing the right projects is extremely important. Doing this will not only help you learn faster, it will provide you with a portfolio of projects that you can write on your resume to impress the hiring managers. If you want to know about the 5 projects that I recommend to all beginners, you can watch this video. My name is Sahil and I will see you in the next one.