Learning a programming language is stretching your skills, as a developer. It’s a new tool in your toolbox, too. With it, you can create something out of thin air. If you’re lucky, others will find your creation useful, and you’ll feel the warmth of being helpful.
Beyond that, I love programming by itself: it’s a game to me. Logic is really fun to mess with.
Learning is fun too: the excitement of discovery, the joy to finally understand a hard concept. It brings more colors to the world.
In this article, I will describe the process I used to learn the programming languages I know. I’ll answer these questions:
- How to learn properly a new programming language?
- What are the best resources to use?
- What mindset to have?
- What tools to use?
- What are the other benefits of this learning methodology?
It doesn’t matter if you are a complete beginner or if you already know a programming language. The process stay roughly the same.
Come with me, dear reader! Let’s go to Programming Land where every variable, functions, and classes live in peace and harmony.
An Environment Where you Can Focus
Let’s be honest: learning a new programming language takes time and efforts. Nothing impossible, but don’t expect programming to be easy.
In general, to learn something, you need to focus on the quality of your learning. If you try to push yourself too much, you won’t learn anything. If you watch some funny Youtube video while learning, you won’t learn much either.
You need:
- A quiet place where you can focus only on what you want to learn.
- A place which is inspiring for you. The best would be somewhere where you can’t be tempted to do something else.
- To choose your code editor / IDE quickly. We want to learn a programming language, not finding the perfect tool. Don’t spend hours on it: just choose the most popular option. You can always change later, depending on your needs. I definitely advise an editor with some sort of auto completion, it will help you a lot.
I have a whole article which is more focus on learning in general, if you’re interested.
The First Step: Learning the Basics of your Programming Language
The basics include:
- Code syntax
- The fundamentals of programming
The first is unique per programming language, the second can be applied to many of them.
Don’t be afraid by the fundamentals if you’re a beginner. You’ll get them along the way.
Finding the Best Resources
To learn the syntax of a new language, the best method is to take a book and copy the code given as examples. It sounds dumb but it’s the most effective to me.
Reading a book is not enough. If you want to learn something, you need to learn actively. Reading is too passive.
If your book is good enough, it will explain to you the basics of the language syntax, some general fundamentals with code snippets as examples. Copy these examples in your code editor and execute them. Play with them.
Don’t try to understand everything in detail while reading the book, especially if you are a beginner. You can go back to it later. For now, the goal is to have a good and global idea about how the language works.
There are a lot of books out there which provide you some code with explanation. I personally really like the whole learn code the hard way collection. Don’t be afraid by the “hard” in the title: it indicates that it will teach you properly what you need to know, without shortcut. This is what we want.
For the folks who already have some experience, these books can be a bit boring . However, it can as well teach you some fundamentals you didn’t know, or refresh some forgotten memories.
You might ask yourself: why a book? Why not following some articles on The Great Internet? Or watching some Youtube video? The quality of the content on the Internet can be very random. You don’t want to take wrong habits; it’s easy to learn inaccurate concepts, increasing your confusion. Learning is easier than unlearning.
A book, on the other hand, can be advised by the community of the language you want to learn. You need to be sure you can trust its teaching: you should ask around in forums, discussion groups what would be the best book. Positive book reviews on a website like goodreads can be a good indicator as well.
You want to avoid misconceptions, “knowing” something which is only partially true or absolutely wrong.
Now, I have a little quiz for you. What’s the best way to learn from these very objective propositions?
- Focusing on your book on a regular basis, from 30 minutes to 2 hours maximum per session.
- Cramming 8 hours of study every two months, your belly full of RedBull, at 2am, when your procrastination can’t let you sleep anymore.
I have no partnership with RedBull and human attention is very short. Learning two hours straight is already challenging. That’s why the first path will make you wise, rich and glorious. You will learn tremendously faster that way.
Take your time, be patient, and you will get there. Don’t forget: the most difficult is to begin. If you have some tendencies to procrastinate, like everybody, try to open your book only for 10 minutes. Close it if after these 10 minutes you still don’t want to learn.
You might be surprised how far this simple technique can lead you.
Assessing Your Knowledge
Come back to the code you wrote from time to time, without the book this time. Ask yourself:
- What did I learned the last time?
- What was the purpose of the examples and what the book tried to teach you?
- What does mean this specific syntax?
- What the purpose of this function?
- What is the output of this example?
This is meant for you to remember the fundamentals and the syntax of your new programming language. Trying to remember what you learned the last time will reinforce your memory.
If you’re really motivated, you can even try to find other solutions to get the same output of your code snippets, for example.
When you write your code, don’t use too many comments! Try to understand the code as it is. It will, most of the time, give you enough information for you to find what was the purpose of it. On top, when you’ll be a rich and famous developer working for the NASA, your colleagues won’t comment every single line of code they will write (I hope). They will expect you to understand the code.
If you have no idea what you’ve written, that’s perfectly fine. Even if Yoda himself said the contrary, trying is the most important.
After your tries to remember what you learned the previous learning sessions, open your book and let these “aha! I remember now!” thoughts of victory blossom in your wonderful soul.
You can test yourself every week or every two days, it doesn’t matter. Simply have a study plan:
- Read the book
- Copy the code
- Test yourself, without the book, from time to time
- Play with the code - modify it, add your own ideas to understand how it really works
- GOTO 1
You need to find your own pace: not too slow or your motivation will suffer, not too fast or you’ll feel exhausted. Find a balance to keep your interest in your new programming language. That’s the most important!
The Second Step: Beginning a Side Project
When you’re half-way in your book, you can begin the second step of this plan to rule the universe: beginning a side project.
Actually, you can begin it whenever you’re able to use the syntax of your new programming language without too many difficulties. Just try and adjust: if it’s too hard to build something, you might not be ready yet.
If you’re totally bored with your book, if only opening it feels like a torture, if you have the despite every page of it, it might be a subtle indicator that you need something a bit more concrete and creative. Hence the side project!
What the benefit of a side project, you might ask? Learning the syntax and the fundamentals of a programming language is essential, but definitely not enough. Programming is about problem solving, and you need to be able to solve all kinds of problem with your new language.
What Side Project Can You Build?
I already wrote a series of articles about side projects:
- The first article is about the mindset to have to carry your side project through its end. Believe it or not, the mindset is the most important!
- The second article focus on the tools I’m using to follow this mindset.
If you need to remember only one thing from these articles: build something small! You don’t want to build the best application of the year and become rich, famous and unhappy. You want to learn a new language.
Your side project could be anything from a todo list app, a pomodoro app or a calculator. Even better: if you have some personal ideas which could be a fun small project, please proceed. It’s even better than picking random ideas on The Internet.
If you want to build something bigger afterward, feel free to do so. Go step by step, begin by something little, and build bigger and higher, if that’s what you want.
The Best Way to Work on a Side Project
You need to know exactly what functionalities your side project will have. I will never say it enough: as few as possible, for the beginning, is the best. You can still add more on top later.
Then, follow these steps:
- Open your code editor.
- Choose the functionality you want to code.
- Code.
- Google is your friend when you’re stuck.
- Hooray! Your functionality works.
- Go back to 2.
This is called an iterative process. Even if you’re wrong at the beginning, you’ll fix your mistakes and come closer to your goals after each iteration. Consider the first iteration as an imperfect draft.
Analysis paralysis can be your biggest enemy as a developer: don’t over think. Code something. Don’t try to find the perfection in these wonderful lines of code. Perfection don’t exist, and it’s ugly anyway.
Don’t spend an awful amount of time searching the best tools either. I would suggest not using any framework for your first side project. If you need some libraries, take the first one advised by the community (or first ranked by Google) and go for it. Even better: code it yourself if it’s not too long (or too boring).
If you feel comfortable, you should try to write some automated tests as well. It’s important to know how the language handle testing. Consider it as a bonus.
The Third Step: Show the World your New Talents
Share Your Code and Grow Your Credibility
If you’re a beginner in the fantastic development world full of unicorns, rainbows and mortal tar pits, you need to get a bit familiar with git. It’s basically a system which allow you to version and push all your code on an external server.
The how and the why of git are beyond the scope of this article. If you want me to speak about that, you can contact me. I would love to hear from you!
Install git on your system and create an account on Github. Then, push your project.
When it’s done, congratulation! You can now show your code to the whole world. This is especially useful if you’re planning to find your first job as a developer. You can show your fantastic side project to anybody who wants to see your new skills.
It’s even better than building a portfolio filled with emptiness!
That’s why a side project is important: it will teach you your new shiny programming language and it will improve your credibility as a developer. More code you will have on Github, more chances you will have to skip the boring and usual interview coding tests. Yes, I hate them.
How nice is that?
Get Feedback From Your Peers
All of that is very nice but there’s something important to keep in mind: working alone on a side project can teach you a lot of crap.
Even if you follow a serious and praised book, you can still misunderstand some concepts. You can as well be victim of illusion of competence, when you think you know something, but you’re not able to use it, or even to explain it. Not really useful in my opinion.
Writing the code from your book and building a side project can prevent you to fill your brain with nonsense, but there is still some risks.
That’s why I would advise you to show your code to a maximum of people. Go to Reddit, forums, Facebook groups, and ask for feedback. Negative ones are the best: they are never easy to handle, but they will teach you a lot, and that’s what we want.
If you know some experienced developers, ask them some feedback too. Heck, you can ask me some feedback!
Having a mentor you know well and who can provide personalized advice would be the best of the best.
Having feedback is great when it’s constructive. Don’t take into account pure criticism without any arguments or explanations. What you want is constructive feedback. They explain your mistakes and give you solutions to fix them.
Does Your Method Really Work To Learn A Programming Language?
This part is not only an ego-centered gabbling about me and how great I am (the about page of this blog is there for that), but more about giving you concrete examples.
How Did I Learn Programming 20 years ago
When I was a young man, I wanted to code video games. I loved playing them, and I had already these weird desires to create stuff on a screen.
My parents, tired to listen to me speaking about it, bought me a book to learn C, for my birthday. I spent months on this book. I was already applying the three steps technique I just explained you, instinctively. I didn’t have Internet at that point, so I didn’t have the choice, and I’m very happy about that.
I read everything and copied most of the code while reading. The book taught me as well all the fundamentals of programming I needed, at a low level. It’s goddamn C.
Halfway through the book, I began to code my first side project: a textual RPG where you could choose your race and your weapons to go on a text-based adventure, in the Windows terminal. Then, I went into a wall: be damned, you pointers!
How Did I Learn Golang in 2018
Let’s go back to a fresher past. After 8 years as a PHP developer, I decided to learn a new programming language to extend my skills. I choose Golang for many reasons. Again, if you want to know them, “comment below” and I will do as you say, master!
- First Step: One of my colleague advised me to read Go in Practice while copying all the code given as example. It’s what he did to learn the language.
- Second Step: Halfway trough the book, I began my first side project in Golang: testomatic.
- Third Step: I shared my code on the Golang google group and on the Golang subreddit. The sweet Golang community gave me valuable feedback, helping me understand the general idioms.
The result? I found a job in may 2018 as a full time Golang developer. My side project testomatic
helped me a lot at the beginning, as a reference to look into, when I wasn’t sure about the syntax. Very useful!
- Bonus step: after beginning my new job, I read Go in Action to understand better the fundamentals and mechanics of the language.
Here’s some cool graphs on the time spent to learn Golang:
First step: going through Effective Go
- On the y-axis are the Pomodoro I did each week.
- One Pomodoro is 25 minutes of focused learning.
As you can see, I began to read the book in January 2018, slowly but consistently: this is the key to learn anything you want. The time I spent on it in March and April increased: this was the notice period from my position of PHP developer to Golang developer.
I wanted to be ready for my new job, and I was enjoying myself.
Second step: testomatic, my first side project in Golang
- The red line represent the amount of work I expected to do each week.
- The blue line is the amount of work I was really doing.
Again, you can see the same pattern: I began slowly but consistently. Then, my motivation went through the roof in March and April.
This is a good example to underline an healthy idea: you don’t have to overwhelm yourself by planning 29 hours of learning a week to make through your side project. Only 25 minutes a day can bring you unexpected results, when it’s done consistently.
You might notice that I never finished the book. When I began to work as a full time Golang developer, I judged that I didn’t really need to. It’s perfectly fine; don’t put pressure on yourself to finish every single book, if you don’t feel like it.
You can always come back to unfinished books later.
How Did I Learn Clojure in 2020
Ah! 2020! You were full or promises. Humanity as a whole saw your potential. We were full of projects, we ended up on our couches, seeing chaos and misery harnessing the world.
Somehow, I still managed to do something I’m pretty proud of: I learned Clojure.
- First Step: I was again advised by a good soul to read the free book Clojure for the Brave and True. This book is so good! The author needs million of dollars and a statue in my living room.
- Second Step: Halfway trough the book, I was still trying to understand the first chapters. It’s a whole new paradigm, so don’t judge me.
- Third Step: After finishing the book, I found a snake game written in Clojure, and I modified it for my needs. I wanted to teach some Vim concepts with it. Here’s the result.
- Fourth Step: Feeling a bit more in control of my destiny, I went on my own project, using a library to build a Sokoban game. I learned a great deal about WebGL at the same time. Why not? I had time.
In this special context, I thought creating funny little games could be nice. Plus, video game development is crippled with states, and functional programming has some interesting ideas about that.
Here are some data:
This is the time I spent in 2020 on reading Learn Clojure for the Brave and True. I copied all the code as well. The red curve was my goal, the blue curve how much time I really spent on it.
In total, 38.75 hours. I spent already 20 hours on it at the end of 2019, so the total is a glorious 58.75 hours.
Again, the hardest is to begin. Then, time flies by!
This is the time I spent to build my two games. In total, 100 hours. Gosh, I didn’t do game development since I was 18. It was good.
The conclusion: if you want to learn a tonne, just pick a language in a paradigm you don’t know, with a weird syntax. Many new skills guaranteed.
A language that doesn’t affect the way you think about programming, is not worth knowing."
There is nothing exceptional here. Just spend 10 minutes each day on the language of your dreams, and you’ll end up spending hours without even noticing it.
By the way: you’re never really done learning a language, and that’s great. Learning is fun!
Coding is The Best Way to Learn a Programming Language
Here’s a condensed version of the learning method described through this article:
- Step 1: find a well-known and rated book, follow it and write the code given as example.
- Step 2: half-way through the book (or when you feel ready), begin a small side project. If it’s something personal, it’s even better. Continue your book and you side project in parallel.
- Step 3: show your code to whoever can give you feedback. Having a mentor is the best!
If you need to remember something from this article, remember that: active learning is always better than passive learning.
I agree that copying code examples from a book and coding your own side project are more efforts than passively watching coding videos on Youtube. However, since you’re a (possible wannabe) developer, you should be able to enjoy it, at least most of the time.
If you enjoy learning a new programming language, can we still speak about “effort” and “work”, or more about “pleasure” and “hobby”?