This article contains affiliate links. See my affiliate disclosure for more information.
Exposure to multiple programming languages accelerated my growth as a coder.
It gave me a toolset to express a problem in multiple ways and compare and contrast different approaches. This didn't immediately make me a better coder, but it set the stage for some significant shifts in thinking later in my career.
Learning multiple languages changed how I think about API design, taught me the value of a rich type system, and fundamentally altered how I think about data representation.
So let's talk about how to approach learning a second programming language.
Picking a Second Language
During my first three years as an undergrad, I learned C++, Java, and C — in that order. Of course, there were challenges, but the syntax and program structure similarities made learning each language progressively easier.
On the other hand, the languages that have had the most significant impact on me as a coder have been the ones that challenged me to approach problems from a different point of view. Python did this to me. So did SQL.
More recently, Rel — a declarative modeling language in the Datalog family I'm documenting at work — has me rethinking everything I know about data representation.
Ultimately, which language you pick depends on your goals. For example, you may choose a language based on its utility in your current role or to expand the number of jobs you're qualified for.
Or you could do it for fun, which is generally my preferred reason to do anything.
Practicing A Second Language
If you want to gain fluency in a language quickly, the key for programming languages is the same as human languages: immersion.
But I no longer have the stamina I had as a student, nor the excess energy I had before becoming a parent. I don't have time for immersion. I need short, focused, and practical techniques that I can do in a few hours each week.
Here's what works for me.
The concept is old-fashioned, but whether you use a digital flashcard system like Anki or make your physical cards, flashcards are a simple and convenient way to quiz yourself when you have a few moments to spare.
I make flashcards for:
- Short code snippets or patterns that are used often
- Built-in functions and methods
- Standard library modules
- New terminology
- Common terminology that is used differently
I still prefer to make decks of physical cards. I like to use small, blank 3" × 5" index cards that fit in my pockets. They're great for getting in a bit of practice during life's dull moments.
Type Everything Out
One of my favorite exercises is to find a well-written codebase in the new language I want to learn and type out code snippets from it. Social media and chat servers are great places to ask for codebase suggestions.
I pick a function, class, or module — usually 20 lines or less — put it in a window next to my code editor, and start typing it out. As I type, I use comments to take note of things I don't understand. Then I'll mull over the code, research questions I have, or even translate the code into a language I'm more familiar with if I have time.
I like the exercise because it forces you to:
- Practice reading the new language.
- Practice writing the new language.
- Connect new knowledge to existing knowledge.
- Expose yourself to knowledge gaps.
- Expose yourself to alternative approaches.
You can complete it in an hour, and it packs a punch.
Document Your Progress
This is the most important advice I have:
Keep a private journal or write in public on a blog. Don't worry about the quality of your writing. Instead, focus on documenting your current understanding of things. Write concept guides that explain how a concept works and why it is important. Make cheat sheets. Keep a file of interesting code snippets with short explainers.
Write. Write. Write.
I don't consider my understanding of a concept complete until I can explain it in writing in simple, clear terms. This never happens on the first try. I can spend months — even years — refining things.
Here's an easy way to start.
Pick a topic you learned recently and answer three questions:
- Why is the topic important for you to know?
- How is the topic related to things you already know?
- What don't you understand about the topic?
Then describe the topic in five sentences or less. File the document away somewhere and return to it a few days later. Underline any parts of your description that confuse you or that you aren't satisfied with.
This five-sentence description becomes an external representation of your mental model for the concept. Your mental model improves as you revisit your description and refine it over time.
Whether you're learning a second language or learning to code for the first time, it helps to have support. All Curious About Code subscribers are invited to join the private Curious About Code Discourse server free of charge.
Subscribe now and join the discussion!
Become a better coder.
One email, every Saturday, with one actionable tip.
Always less than 5 minutes of your time.