12 ways to study a new programming language

You've decided to learn a new programming language. How do you get started?
484 readers like this.
An introduction to GNU Screen

Opensource.com

So, you've decided that you want to add a particular programming language to your repertoire. Now what?

In this article, I outline 12 suggestions for study techniques. Remember that everybody learns differently. Some of these techniques may work excellently for you, whereas others may not meet your needs at all. If you start to feel stuck with one strategy, try another and see where it gets you.

1. Compare it to similar languages. As you watch your first tutorials about a language or read code in it for the first time, try to guess what each part of the language will do and check whether you were correct. If taking notes helps you synthesize information, grab a piece of paper and jot down three lists:

  • things that look familiar, and look the way you expected them to;
  • things that look familiar, but do something unexpected;
  • and things that look totally new.

For instance, if I do this exercise with Rust code coming from a Python and C background, I'd put curly braces for scopes on the first list, ! (looks like boolean not, but is actually macro definition in Rust) on the second list, and type signature syntax on the third.

If you hold onto a copy of your initial list, you can use it to reflect on your progress through the language once you're more proficient, and remind yourself what concepts seemed unfamiliar when trying to teach the language to others.

2. Read the language's official documentation. If you prefer to absorb a lot of information before jumping into using it, you might benefit from reading the language's reference materials. Don't worry if they put you to sleep, though; reference docs are generally written to be searched through rather than memorized.

3. Search the web. Searching the web is a great way to turn up information on specific errors and general best practices. When you get an error message, search for part of it that looks unique to this error but not unique to your code. For instance, if the error says "Error on line 53: Invalid argument exception", search for the language name and the string "Invalid argument exception" to find the best results. Remember to include the quotes around whatever you took verbatim from the error message.

You can also search the web for blog posts on best practices for solving a particular problem in a language. When assessing the quality of blog posts that appear in your search results, check out the author's public code portfolio as well as the date on the post when deciding how seriously to heed their suggestions.

4. Engage with the community for support. Although blog posts and news articles have plenty of generally useful information, there are always subtleties to the particular piece of code that you're trying to write. Don't be afraid to post to a mailing list or join an IRC or slack channel to ask for help.

To ask questions that get helpful replies, make sure you're asking in the right place. Many languages have a "beginners" mailing list or chat channel specifically for questions that might get asked frequently. When you ask a question, be sure to summarize what you're trying to do, what you've tried, and what happened instead. Try to provide enough context for an expert to understand your problem, without irrelevant details. After asking a question, make sure to stick around for a while to listen to the advice or answer follow-up questions that your inquiry might have generated.

5. Write toy programs. To practice one new concept at a time, few tasks beat writing a toy program that uses only that concept. You can focus on getting your code as clean and idiomatic as possible. If you solve a Project Euler or Rosetta Code puzzle as a toy program, you can often compare your solution to those written by others for the same problem in the same language.

6. Write production-ready code in the language. Although toy programs are a great first step, using a language in a more realistic setting can help you explore its real-life advantages and challenges. Consider porting a familiar, relatively small, well-tested program into your new language to explore its applications to real life.

7. Read a book about the language. If there are several books available, compare their reviews, and also consider which author's background is most similar to your own. Many ebooks are available free online.

Before purchasing a book about a language, check the date that it was published and the versions of the language that its examples cover. If you're using an older book, be sure to try the examples in the language version that it assumes. Research online to learn how the language has changed since the book was published.

8. Watch lectures and courses. If your language is taught in an online course, the videos might be publicly available. In addition to academic lectures, consider looking for recorded workshops, conference talks, and podcasts about the language. Putting on a talk about your new language when you would otherwise just be watching TV is a great way to slip studying into your daily routine.

9. Read example code. Most books on programming languages will include code snippets. You can also find example code in blogs and on Rosetta Code. Run the code examples, modify them, and try to predict what behaviors the modifications will cause.

10. Read production code. One way to find projects of all shapes and sizes in your language is to search for it on GitHub. Sort by the most-forked or most-starred repos, and your top few hits will include the language's most popular open-source tools. If you're trying to understand an open source project's design, it can be helpful to engage with their community on mailing lists or IRC. And you might even find some bugs while you're at it.

11. Find good tools. As you work with a new language, ask its more experienced users about their development environments. You might find that one particular text editor or IDE has universally better support for the new language than the one that you use out of habit. Investigate what options exist for managing dependencies, formatting, fuzzing, and unit testing code in your new language's ecosystem.

12. Maintain your enthusiasm. Getting started with a new language is easy, but becoming truly proficient at it is often a journey that takes years. Celebrate your successes along the way, and share what you've learned with the learners who are following in your footsteps, to keep the hobby of studying programming from turning into a chore.

Do  you have additional tips for learning a new programming language? Let us know about them in the comments.

User profile image.
E. Dunham is an open source geek of many trades, currently working as a "DevOps" Engineer for Mozilla Research. This role has applied skills learned at the OSU Open Source Lab and a variety of other companies to improving the Rust programming language's tools and infrastructure. Other hobbies include writing, gardening, and enjoying Oregon's outdoors.

2 Comments

The flipside of this is the question of where there are roadblocks to learning a language.
For me, the main one has always been the documentation and tutorials. Much of the official documentation and references that I find are like trying to read a legal contract written in the language that only lawyers understand. You may find some template on how to use some command, but can't understand what the template is saying. A big help is always examples that illustrate what the template is indicating.
As far as unofficial documentation, some is excellent, but often you have a choice between r-e-a-l-l-y elementary examples of interest to no one, or far advanced and complex examples you can't figure out. Most of the articles titled "An Introduction to XXXXXX Programming Language" aren't worth the space they take up.

Getting engaged with the community is really worth. When you join or form a community that evolves around a particular language; you get to meet many people - from highly experienced professions to excited freshers who are all enthusiastic like you. This makes your learning path easy and more exciting!

Creative Commons LicenseThis work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.