The Best Way to Learn a New Programming Language from Scratch - How I Approach and Learn Any Programming Language Efficiently
Planted June 4, 2024
Preface: The following article is based on my experiences and opinions on learning programming languages. I have been learning about computers in-depth and find learning languages with specific purposes useful. For example, Python was for beginning, C is for memory management and Rust is for learning to write memory-safe code in my case. This time, I started learning Golang which is known for its simple syntax and powerful performance, and widely known for its awesome concurrency. This time, I considered documentation on how I approach new programming languages when I have a requirement, such as for projects or work-related purposes. Note that your experiences and opinions may vary; I greatly respect that.
The Motivation to Learn a Programming Language
There are a lot of languages out there which are built for specific purposes and when you are working on diverse projects, it’s often necessary to learn a new programming language to make the best out of it. Some languages are easy to learn and few are mind-numbingly tough to understand. A few of them start harder and once you grab that one or two concepts, it becomes better (like Rust) and you start loving it despite it being different. Some start really easy and end up tougher and tougher (like C). In both cases, experience is the key. In this article, I will be focusing on the very beginning stage of learning a new programming language, just before you start working on that specific project you need to get done. Trust me, it’s always easier to learn a new programming language when you are comfortable with one or more before learning that new language. Learning programming languages is just about learning how to talk with the computer with new syntax (and often with newer methods of managing resources and stuff, like borrow-checker in Rust and manually managing memory in C). But most of all, it’s just about learning how computers interact and work upon a given piece of code. To start learning a new language, you must start with a motivation to learn the language. Like why do you want to get that one language in your skillset? You need a strong reason to learn that new language. Learning a lot of languages without knowing why you learned all of them doesn’t make you a good software engineer. If you don’t have a strong reason to learn that new language, leave it. You should practise and build upon your existing knowledge. But if you have got a strong reason to learn that new language, keep that one thing in your mind and then start working with it. In my case, I was going to learn golang because of its simplicity and concurrency. Let me be honest, I never learned to write concurrent code and I just wanted to get started with learning to program software that can work with multiple processes in parallel and make my programs faster. Golang is one of the best languages to get started with learning concurrency and while I was writing this article, I already learned about go routines, channels and pipelines. And in a few days with practice, it would be easier for me to use concurrency in my programs.
The Best Resource to Start With
The very best resource to start learning a programming language is to start with its official documentation. I know videos and bootcamp lectures are comforting and you understand what’s happening around there, but reading is the single best resource that has helped me learn multiple programming languages. You have to put that habit of sitting for hours, staring at the screen and scrolling documentation all along while copying, pasting and modifying existing code into your code editor and running it. This helps you get hands-on experience and understand the behaviour of that language. Trust me, watching or just reading would not make you better at that language, writing and analysing behaviour of it would do it. When you see a snippet of code in the documentation, read and try to understand it. Execute it and analyze its behaviour. Move ahead and experiment with it. Add more code to it. Don’t worry when it crashes, you are still a beginner. When you are stuck somewhere, and the documentation is failing you to explain that, fire up your search engine and search for resources. You need to keep your hand on the keyboard and work on it. The reason why I recommend using documentation is that it’s made by the official people who built the language itself or is maintained by the organisation that developed the language. They want you to understand the language and use it. They want as many people to use it and make it popular. So they give a lot of effort and make sure to reduce as much as friction possible to make you understand it. These documentations are free to use and anybody can access them. So there is no monetary friction to it which would keep you back. It’s the best and you have to refer to it anytime when you start writing code in that language.
How to Approach Programming Books
When you are done with reading the documentation and understand its basics, and you have practised enough for that, you are ready to go for specialised books. Now there are two types of beginner books that I believe exist in the market. One is the category of books related to a specific topic. For example, there is a book named “Concurrency in Go: Tools and Techniques for Developers” by Katherine Cox-Buday which focuses on Concurrency in Golang. These types of books in my opinion are awesome since they focus on one topic written by an expert author. Reading these types of books can make you better at that language and help you grasp all those topics individually. Other types of books are books for general learning of the language. I believe these books are not recommended for reading in most situations. You have gone through the documentation and are familiar with the syntax, so you might not need to go through them specifically from a book. Unless it’s the case that something is not clear in the documentation and you need another material to go through just for the sake of understanding better, then it’s okay to have it, but mostly, they are not just that good to work with. And I would recommend that you go through these books as you gain experience and not binge-read them. It’s good to have more and more knowledge, but if you are not applying it somewhere, then it will not help you. When you read these books, you have an overall acknowledgement of the topics, you don’t need to have them fit into your mind while you code. So it’s recommended to keep these books handy while you code in that language to just go through the concepts that you like and eventually, you would get that thing retained in your brain, making you a better programmer than before.
There is No Substitute for Practice and Repetition
Reading and understanding the language is one thing, but the application of the concepts you learn will let you know where you lack. When you read literature, it’s difficult for you to remember all of it. And when you are in the practical phase, you will certainly forget a lot of it. And you don’t need to memorise it. You have the documentation and books with you. But the fact is that as much as you write code in that language, you will become better at it. There is no magic pill for that. You have to get your hands on the keyboard, fire up the text editor or IDE and start writing code. To learn the syntax better, I would recommend that you solve a few problems. Like from competitive coding platforms, or find problems to solve and then start writing code for it. Try to write as optimal a solution as possible, since a lot of time we tend to write longer and unoptimised code to skip a certain method in the language which we don’t realise and end up not learning it. Look for solutions by other people. Now I am not recommending that you grind up that much and keep solving questions. Once you get comfortable with writing the basics, start building a few projects. Let them be small initially since they would be finished quickly covering a lot of topics and will be as less repetitive as possible in terms of methods. Move on to the bigger eventually and keep learning. Use your search engine, it is one of the best tools made for software engineers. Use AI but not copilot or AI-based completion tools unless you have mastered it. AI is super helpful while writing code and it would explain it to you like an artificial mentor.
Programming Videos? Great for Entertainment and Learning
Programming-based videos are good and can be helpful in your learning journey. But they should be taken with a pinch of salt. I recommend that you watch programming videos for entertainment and learning. A lot of things can be deduced from videos related to programming other than the language itself. You can get a lot of insights from the programmer making that video and especially for me, the enthusiasm motivates me to further learn the language in depth. I don’t recommend learning languages from videos or boot camps that go for long hours (it’s okay to learn a few concepts that are not clear from the documentation itself or other resources, but not the whole language). Especially learning a whole language by binge-watching these videos is not a good idea. Keep them as an extra resource which would be used when nothing works out. I love watching videos that go into explaining concepts related to a specific mechanism (and not the syntax) or videos that just talk about it. There are a lot of creators that go through a lot of things related to that language like comparing it with other languages, finding pros and cons, finding metrics, etc. They kind of motivated me to learn and find more things about the language. Like I can’t stop to implement it or write about the good things that I found out about it. These types of videos can entertain you, especially after a long coding session. In the end, it’s necessary to enjoy the process and not the destination of being the best programmer in that language. You would get better and better, eventually leading to being a master of that language, but it’s important to enjoy each stage of learning the language. As a beginner, the excitement of learning that language is the motivation that will drive you. Once you better an intermediate-level programmer in that language, you will get excited to learn more in-depth than you would believe not a lot of people know. Building stuff would make you realise how little you know and will push you to learn and become better at it.