Amy M Haddad

How to Learn a Programming Language

By: Amy M Haddad

image

Whether you’re learning your first programming language or your tenth, this article contains the resources to use and the techniques to apply to really learn a programming language.

I’ve learned several languages, some better than others. As I’ve found out first-hand myself, learning something well depends on your system. The better the system, the better the learning. I’ve refined my own language-learning system over the years to a simple recipe, which I’m going to share with you now.

What then How

What you choose to focus on always comes before how you do it. You can be the best learner on the planet, but if you're learning the wrong topics you’re not going to get where you want to go. That’s why I begin this article with what resources you ought to use to get up and running with the language of your choice.

Once you know what to focus your time and attention on, the other critical piece of the puzzle is understanding how to go about it efficiently and effectively. In some cases, I offer suggestions of how to use the recommended resources as I mention them. I also provide several learning tactics you can apply more generally towards the end of the article.

Now let’s get learning.

1. Exercises for Programers

Brian Hogan’s book, Exercises for Programmers, is a gift that keeps on giving. The exercises aren’t tailored to a specific language, so you can solve an exercise in Python now and JavaScript later. It’s the place to start to gain familiarity and confidence with the basic syntax and data structures of your language that you’re learning.

The exercises are organized by topic, such as conditionals, data structures, and functions. From there, you’ll get practice with things like generating a random number, getting user input, and converting between data types.

You’ll find that the provided exercises are like an onion: you can solve the same exercise over and over again and gain new insights each time. That’s because Hogan offers one or more constraints and challenges for each one.

2. Exercism

Once you’ve got some basic knowledge of your language, you now want to turn to Exercism. There are three reasons why.

First, this free platform offers an assortment of problems that’ll get you familiar with the standard library for your language. It also introduces the idioms and patterns used in the language. These are reasons enough to solve problems on Exercism.

Second, you’ll get familiar with testing in your particular language. Each problem contains tests. I like to study these tests to understand how to write them in the language I’m learning. I also use them to get practice with Test-Driven Development (TDD).

Here’s how you can apply TDD to Exercism problems:

  • Sign up for an Exercism account and select a problem to solve in the language of your choice.
  • Open up a new file in your text editor and write your own tests to solve the problem. Ignore the test file that’s provided.
  • Write one test at a time and follow TDD principles as you go.
  • Once you’ve solved the problem—and written tests—then compare the tests you wrote with the ones provided by Exercism.

The third benefit Exercism offers is its free mentoring. I can’t speak on behalf of all of the language tracks Exericism offers. But I’m working through its Go track now, and have been amazed at the quality of feedback I’ve received on the problems I’ve solved. My learning has definitely accelerated because of it.

3. AlgoExpert

Now it’s time to level-up your language knowledge by solving algorithms. I’ve cycled through many algorithm resources, and AlgoExpert is the best.

The video explanations that accompany each problem are a point to highlight. They consist of two-parts: a conceptual overview and code walk through, where you’ll get a line by line explanation of their provided solution(s).

I highly recommended watching both parts. Yes, it’s important to understand the solution. But it’s equally important to understand the concepts behind it, which is why the conceptual overview is so valuable. Instead of big leaps, you’ll find clear and thoughtful explanations on core algorithm concepts. Rather than memorizing, you’ll find yourself really understanding.

I’ve found it beneficial to work through problems on AlgoExpert in conjunction with Advent of Code and LeetCode. Take what you learn and do on AlgoExpert and apply it to other problems. This is a great way to exercise what you’ve been learning.

Learn It and Retain It

No matter where you’re at in your language learning cycle, there are several learning tactics to try.

Make It Active

The best way to learn is to do. That’s why you ought to give the Apply First Study Second approach a try: actively apply your knowledge first by trying to solve the problem; then turn to passive modes of learning (such as reading a book or watching a lecture) when you get stuck in order to get yourself unstuck and to take a deeper dive into a particular trouble spot. In short, get the information you need when you need it. And you’ll know what you need by trying the problem first.

Oftentimes we can draw upon our existing knowledge to solve (or attempt to solve) a problem before turning to passive modes of learning. We simply need to apply our knowledge in a different or new way, which is precisely what the Apply First Study Second forces you to do.

Besides, the learning is much more meaningful if you try first. You'll identify the roadblock: the one thing that's preventing you from progressing further. Then you'll turn to passive moves to learning with purpose because your mind is on alert: you’ve got a particular roadblock at the forefront of your mind as you begin to watch the lecture or read the book. Once you get what you need, you've got a situation where you can apply your knowledge.

If you’re brand new to programming, you may find it useful to learn just enough, then apply right away when it comes to concepts that may be unfamiliar, like functions or classes. By “just enough,” I mean get the big picture concepts but don't get lost in the details. Then continue on with the iterative Apply First Study Second approach: get as far as you can on a problem and only consult a resource if you get stuck.

Study the Code of Others

Another learning technique to try is similar to one Ben Franklin used to become a better writer, where he tried to reproduce an article from a publication he admired—after he’d forgotten the details of it. A similar process can be applied to programming.

Here’s how it works:

  • Solve a problem.
  • Find a programmer who’s solved the same problem.
  • Study their solution. Read each line of code and type a comment in your editor to explain the line of code: what’s happening and why.
  • Let some time pass, and then re-solve the program. Use the comments you typed out as hints to guide you along the way.
  • Compare your new solution to the one you studied.

I’ve written about this tactic in a previous post, and there’s a good reason why I keep bringing it up: it works really well. This technique is an excellent way to get better at reading code, add new tools to your programming toolbox, and solidify concepts. It’s low-hanging fruit that all of us ought to apply, particularly when learning a new language.

Stay Sharp

Have mechanisms in place to stay sharp with previously learned material. There are two suggestions to try. One is to use Anki, a free online software program. Anki uses spaced repetition. It's a learning technique where you repeatedly review a topic over time.

For example, you may see a new flashcard today. Then, you may see it again in ten minutes, a day, a week, ten days, a few months, and so on. You influence how quickly you see a card again based on given time periods, which can vary. The idea is to retrieve information over time at different intervals; challenging cards are shown more frequently than easier ones.

Another way to stay sharp is to complete a Weekly Spot Drill. Once per week, work on a problem related to something you previously learned—and unrelated to what you’re currently learning about or working on. Say you’re learning about arrays right now. You want to stay sharp with strings, which you’ve previously learned about. So you select a string-related problem this week. That’s your Weekly Spot Drill.

The Weekly Spot Drill will keep your skills sharp—helping to ensure that you’re ready, not rusty—and deepen your knowledge. That's because you'll uncover another layer each time you revisit a topic. Plus, this practice will teach you to pivot: to use the best tool to solve the problem, not necessarily the one you just learned about.

Above all, be consistent. Show up and do the work each day, whether that’s 30 minutes or three hours or somewhere in between. Habitual effort towards language learning helps to keep the concepts sharp in your mind and fuels motivation because you’ll see the small strides being made each day. These small strides compile up over time, resulting in the big leaps you’re after.


← back to all posts