Want to pick up a new programming language? Great! I personally think that the landscape of programming languages has never been more exciting than it is now - there are a multitude of languages to pick from, and a true professional is polyglot (from Wikipedia: Polyglotism or polyglottism is knowledge of several languages, consisting of the ability to understand, speak, read, or write these languages). I won’t help you pick a language from the pile - that is entirely based on your coding level, language skills, ambitions and the direction that you’d like to take your career in. But I’ll help you approach the actual process of learning your programming language of choice.
Unsure about how to approach such a big task? You are probably not the only one, so let’s spend some time figuring out a methodical approach that will have you covered not only for your next learning session, but for all future learning sessions as well.
Learning a new programming language is hard work, but thankfully we live in an age where most - if not all - the resources you need, are available online. Most of them are free as well. All you need to get started is motivation, your favorite search engine and this “tutorial”. And perhaps a few extras, but let’s worry about that later.
Whatever approach you take to learning your new language, there are some very specific subjects that you should cover in order to gain a comprehensive understanding and knowledge of the language in question. Without further ado, let’s see what they are:
The basics
- Syntax
- Type system
- Error handling and recovery
- Debugging
The ecosystem
- The standard library
- Package management
- The community
- Frameworks and libraries
- Tools
Background
- Books
- Language announcements
Achieving proficiency
- Design patterns
- Idiomatic usage
- Exercises
- Projects
Each subject is covered in more detail in the following. I’ve decided to split them up by the headlines above and use a Purpose -> Steps -> Reasoning structure so you can easily get an overview of what to do in each case.
The basics
Purpose: First of all, you want to get familiar with the syntax of the language. Focus on discovering where and how the language differs from the language or languages that you already know.
Steps:
- Go to Amazon.com and place an order for an introductory book for your language. It either needs to be fairly recent (published within the last year or so) or of the “Bible”-kind. I think you know them: they attempt to cover the entire language from A to Z and are often republished in order to stay up-to-date as the language and best practices around it evolve. Look for books that are popular, and use Amazon’s “Look Inside” feature to learn 1) if the book is communicating on a level that is pleasant and understandable, and 2) if it covers the topics that you feel that you might struggle with. If you prefer e-books, go ahead and find one that has the same qualities as just described.
- Many modern programming languages have their own website with tutorials and guides on how to get started. Use them! They often contain plenty of examples and live code that you can run in a playground. There will be exercises such as “change the value of x and see what happens”.
- Find an online playground for your language where you can do live coding, or start a learning project on your machine. In regards to the type system, you need to know which types are available, how to convert between them and what to look out for during conversion. Dynamic languages such as PHP, for example, will convert numbers to strings when you perform string operations on them, so ask yourself: Is this conversion predictable? Does it retain precision on floating points, or should I call a function from the standard library to achieve this? What happens when I convert it back into a floating point number? In JavaScript, you can compare any two values, but under which circumstances are they considered equal? How do you test for empty and uninitialized variables? The same questions apply to statically typed languages such as C++ and Java, but without automatic type conversion you’ll need to spend some time learning how type conversions work in practice: which functions to use from the standard library, and which constraints they exhibit. Do the conversions and familiarize yourself with the error messages as well.
Reasoning: Tutorials and exercises are important for getting some hands-on experience and for learning about gotcha’s, edge cases and unexpected behavior in the language. This experience will keep you productive when you put your hands on your first real project.
The ecosystem
Purpose: Once you start writing actual projects in your new favorite language, you’ll need to find, examine, import and integrate with other people’s code, be it official libraries or open-source projects.
Steps:
- Get familiar with the language’s package manager: PHP has Composer, Python has pip, Node.js has NPM, Ruby has gems, and so on. Sometimes, there will be alternatives. Learn about them: why do they exist, and are they worthwhile to learn? You need to know if there is a public package repository, such as those that exist for Node.js (npmjs.org) and Perl (cpan.org) or perhaps just a central location for their documentation, such as for Golang (go.dev). Search for some example packages you might want, read their documentation, try to install and play with a few of them to get familiar with package management. Read the documentation for your package manager - does it describe how to upgrade/downgrade a package? How to uninstall it? Where are packages installed, and how are their dependencies managed? Get familiar with the ecosystem surrounding package management, and also the community surrounding it. You probably don’t need knowledge on how to publish your own packages just yet, but you will need to know how to properly make your own in a modular and reusable way, otherwise you won’t grow beyond those tiny utility-style applications.
- Go look up some of the most popular packages or open source projects written in your new language. Look at their approach to code structure, naming standards, error handling and what else you can learn. But also look at their package dependencies. Take notes! Some things will leap at you immediately: perhaps several open source projects use the same packages for OAuth, date manipulation, PDF generation, logging and so on. Bookmark those packages. Take a look at them and decide if they could be useful to you. If you have joined a Slack channel or forum where you can talk to fellow coders, ask them about these packages. Maybe you’ve been looking at old projects and nowadays everyone is using popular alternatives to what you thought were prime dependencies in your own project.
Reasoning: When learning a new language, I personally like to look up some of the most popular packages or open source projects written in that language. You can learn a lot from these because they are written by people who are more experienced than yourself. The knowledge is out there, you just need to reach for it.
Background
Purpose: Learning about a language’s history is an important part of learning that language, so look into it and try to form an opinion. By knowing about the language’s history, you’ll also know which class of problems it was designed to solve, which approach the authors took, and you’ll have a better idea of which class of problems your new language will be unsuitable for.
Steps:
- Look at the language’s Wikipedia page. Who created it, and when? And what has happened since then?
- Look for alternatives to the tools that are provided by the language authors. I’m not saying that you should use them, but you need to know about them. For example, Node.js has an NPM alternative called yarn. Ask yourself why the authors of yarn saw a need for an alternative. Which problems were they trying to solve, and were they successful, in your opinion? The same goes for the language itself. PHP has a fork called Hack, developed by Facebook to solve some of the problems they had with PHP. Which problems? Is Hack worth using today? This is simply about “becoming aware” so that when a colleague asks: “I hate X, why didn’t someone build Y to replace it?”, you can not only answer this type of question, but you’ll also have the confidence to know that your exact choice of language and combination of supporting tools, libraries and technologies didn’t happen by accident.
- Find a news site for your new language and see what’s going on in the community. Is the language and its tools moving in a new direction? Are people unhappy with a certain feature? If you know that a highly anticipated feature is coming soon, you might start preparing your projects for it so you stay on the bleeding-edge of what the language has to offer. Twitter and Reddit are good sources for this, but there are many others as well.
- Look for articles on Medium.com, but don’t just take everyone’s word for what they’re saying. Ignore the haters and go for the articles that display some real insights and sophisticated views. The success stories are also worth reading as they help you identify what the language is good at.
Reasoning: Make an opinion of your own, but never stick to it against all odds. If someone has a good argument or compelling evidence that contradicts your loosely founded but otherwise firm opinion, don’t be afraid to change it. It’s part of the learning process.
People pay attention when eg. Python’s “Benevolent dictator for life”, Guido Van Rossum, decided to quit due to community issues, or when Oracle bought Sun Microsystems and took over Java. These events are sometimes just background noise, but not always. Sometimes, they have a profound impact on the community, the licensing model, people’s perception of the language and so on.
Achieving proficiency
Purpose: Every single language was designed to be used in a specific way, or a range of ways. It’s an approach to software development known as idiomatic code. Some language authors talk more about this than others, but it’s always there, and it’s always worth learning. Otherwise, you’ll end up fighting against the language itself, and you’ll start blaming it for what appears to be its shortcomings. Remember this: if your new and shiny language simply had all the same features that you have grown to love from your previous language, then there’s no reason for its existence in the first place. Languages exist because they have different strengths and weaknesses in relation to different types of tasks, and theses differences are expressed via the language itself: its syntax and choice of features. And equally important: which features the authors have decided to omit.
Steps:
- If you haven’t read it yet, then get a copy of “The Pragmatic Programmer”, this book should be on every developer’s bookshelf. It’s excellent for learning the best practices from your peers.
- If you haven’t heard about Uncle Bob’s “Clean Architecture”, now is the time to get familiar with it. Find some online resources or buy his book, I highly recommend it. Then think about how to apply it to a project using your new language. Think about how to achieve decoupling and inversion of control via dependency injection.
- Look up the design patterns from The Gang of Four, and figure out how to apply them in your language. Also realize that these patterns are not useful for every single language out there, there are exceptions.
- For any language in general, look up SOLID, the software design principles for making software more understandable, flexible and maintainable. These are useful principles to know even when they’re not directly applicable to the language you’re currently learning.
- Start a hobby project of your own. You’ll quickly forget what you’ve learned unless you put it to use. Take your favorite PHP library and convert it to Python, automate something at your work, or go make contributions to an open source project. You’ll soon realize if there is something in the initial learning phase that you missed, for example how to stream bytes from a reader to a writer, how to ask for input from the console, or whatever it might be.
- Visit a challenge-based learning site such as codewars.com where you can solve challenges in your new language and see what others have done to solve the same problems. It can be quite addictive!
- Don’t hesitate to use StackOverflow when you feel stuck!
Reasoning: Learning the strengths and weaknesses of a language is a very important skill to have as a developer. Thinking that your new language of choice is the answer to all the world’s problems is a rather narrow-minded mindset to have, and sometimes a project is simply easier to solve in a different language than your current favorite choice. Knowing when to switch to another language is an important skill to have.
Oh, and don’t forget to have some fun along the way. Good luck!