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 can you properly learn a new programming language?
- What are the best resources to use?
- What mindset should you have?
- What tools should you use?
- What are the other benefits of this learning methodology?
It doesn’t matter if you’re a complete beginner or if you already know a programming language. The process remains 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 effort. Nothing is impossible, but don’t expect programming to be easy.
In general, learning something new means 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 videos while learning, you won’t learn much either.
Here’s what you’ll need:
- A quiet place where you can focus only on what you want to learn.
- A place which is inspiring to you. The best environment would be somewhere where you won’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 focused 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 new, you need to learn actively. Reading is too passive.
If your book is good enough, it’ll explain 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’re a beginner. You can go back to it later. For now, the goal is to have a good idea about how the language works.
There are a lot of books out there which provide code with explanation. I personally really like the whole learn code the hard way collection. Don’t be afraid by “hard” in the title: it indicates that it’ll teach you properly what you need to know, without shortcuts. This is what we want.
For the folks who already have some experience, these books can be a bit boring . However, it can still teach you some fundamentals you didn’t know beforehand, or refresh some forgotten memories.
You might ask yourself: why a book? Why not follow some articles on internet? Or watch some Youtube video? The quality of the content on the internet can be very random. You don’t want to learn bad 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 and 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?
- Focus on your book on a regular basis, from 30 minutes to 2 hours maximum per session.
- Cram 8 hours of study every two months, your belly full of RedBull, at 2:00am, 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’ll learn tremendously faster that way.
Take your time, be patient, and you’ll get there. Don’t forget: the most difficult part is the beginning. 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 projects 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.
- 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!
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 Goland 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 ton, 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. — Alan Perlis
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”?
This article was written by Matthieu Cneude and was originally published on The Valuable Dev, a blog focusing on the important and timeless concepts in software development. You can read the piece here.
Get the TNW newsletter
Get the most important tech news in your inbox each week.