Learning a New Programming Language

In the past year I left my position as a Web Developer to work as a Software Developer. Not only did I leave web development behind, the core languages I use every day changed. I switched from a primarily PHP/Javascript developer to a Python/C++ developer. Changing a tech stacks created a need for me to learn a lot about a new language very quickly, I’ve decided to write down some of what I learned.

Why learn something new?

Unlike me, there’s a good chance you didn’t change jobs recently, so why learn something new? The answer varies from person to person. You don’t need to change jobs to learn a new language. Best practices can differ between languages, so learning a new language might make you more proficient at your current language. Changes in code structure, language features, testing, compilers, etc all make you think differently about your work. Training yourself to think differently can make your old languages new again. Sometimes it’s just good to break up the monotony of your day to day, a new language can be that break. You don’t necessarily need a good reason to learn something new, sometimes its the the motivation to learn something new.

Always be learning. Our industry evolves incredibly fast. So fast, in fact, that keeping up with trends can feel impossible. Learning something new will expose you to trends you’ve never heard of before. Staying ahead of the curve in programming trends can pay dividends. If a day comes when you decide to make a career change, having a leg up on the competition will go a long way.

So, what’s the best way to pick up a new programming language?

Books

Almost every language out there has a book (or many) written about it. Whether it be learning the basics of a language or picking up some best practices, there’s a very good chance that a book exists somewhere on the subject. Books can vary greatly in quality, so I like to choose from publishers I trust (PragProg, O’Reilly, and Manning are some of my favorites).

Doing a little bit of research before picking a book up can help in choosing the right book. Is the author an expert in their field (they don’t always need to be)? Have you read anything from the author before? What do other people say about the book? Who published the book (editorial quality can make a break a book for me)? These are questions I like to ask myself when picking new books up.

Read some code

If you want to know how to write in a new language the right way, look at how others write code in that language. Look at code from major projects in your language. Pick out some popular devs on GitHub to follow to see how they commit code.

Code is code, all languages ultimately run on a computer. Once you learn a language, learning a new language is considerably easier. There are drawbacks, however. I’ve found that breaking habits can be hard. For example, in PHP I coded almost exclusively in an object oriented fashion. Whereas in python I focus on namespaces and functions, limiting classes and objects due to features of the language.

Don’t know what’s popular in your new language? Check out GitHub’s trending page to see what’s trending in your language. Also be sure to check out the topic page for your new language. Remember, want to know how to write quality code? Then you need to read quality code.

Koans

One of the neatest ways to learn a language I’ve seen is to find a Koans project in that language.

A kōan is a story, dialogue, question, or statement which is used in Zen practice to provoke the “great doubt” and to practice or test a student’s progress in Zen.1

A programming koan is basically a set of unit tests you’re handed that you need to make pass. You’re provided the answers, you just need to fill in the blanks with your code. If you’re the type of person who learns by doing, I’d highly recommend finding a koans project in your language.

Some popular Koans projects:

Mentorship

One of the best things about my new position was that from day one I was assigned a mentor on my dev team. Not every company provides this luxury, but there are some other solutions. You may need to take matters into your own hands. Finding a great community of developers can lead to great mentorship opportunities.

Find a mentor in the community.

Many dev communities have a way for helping mentors and mentees find each other. You usually just need to ask. My local dev community, SFDevs, maintains a #mentorship channel within our slack group to help facilitate a productive mentorship community. Figure out where the best place to ask is in your dev community and ask, I think you’ll be surprised at the number of people who are eager to help others.

Find a mentor online

For one reason or another, finding a mentor locally may not be an option. Luckily, there are many great tools to help facilitate mentorships remotely. Interact with developers on Twitter and Reddit, ask questions. Leveraging your network can open doors to find a mentor online. Finally, a quick google search will return multiple formal online mentorship programs available to you.

Ask an expert

Figuring out who an expert is in a field is key. Many developers are active an approachable online. Finding the right community or forum to ask experts questions can make learning your next language easier.

It’s important to remember not to abuse this. While many are willing to help, it’s up to you to learn. Respecting other people’s time and energy will go a long way to ensuring others will help you in the future.

Meetups

If you’re not attending your local developer meetups, you should be. Meetups are generally free and open to area devs. These events are being put on because people want to share with others. Taking advantage of a resource like this is low effort and can have huge returns. Not only will you stay abreast of trends in tech, the people leading these meetups are often senior devs in the community. Looking for your next job is way easier if you already know the best devs in the community.

Contribute

Another option if you’re the type of person who learns by doing is to contribute to open source. Find a project you think you could be passionate about and help. Still not sure how to jump in? There are tons of great resources available for getting started with open source contributions. Here’s a list of a few I like:

Dive In

As others have noted before, once you learn one programming language, others come more quickly. One of the best pieces of advice I’ve received over my career is to go all in when learning something new. When you fully commit, it’ll be easier to overcome the hard parts. Count your small wins, there will be lots early on, so build on those early successes when learning gets tough.

For me, finding the motivation to learn something new has always been my biggest hurdle. I had done some python work in the past, I had never worked with c++ before, so I had to pick up the basics in a hurry. What worked for me may not be what works for you. I hope this helps you with your profesisonal development. Good luck!