Learning A New Programming Language
I’m currently learning Clojure. It’s been several years since I’ve spent this much time learning a new language, and this one is so different from the dynamic languages I’ve been using for work for years. Here’s what helped me stick to learning a new language:
Use a REPL
Learning a new language means making many mistakes with unfamiliar error messages. A REPL environment lets me explore code one line at a time with quick feedback, which makes me feel less overwhelmed. If I forget how to do a particular task while I’m writing code, I always turn to my REPL to help me refresh my brain.
Luckily, Clojure has really great REPL tools. Setting up CIDER to work with my editor (Spacemacs/Emacs) lets me run code constantly in my editor and has made the learning process much more pleasant.
Copy as Much Code as You Can
I type and run nearly all of the code I see in books and screencasts. Reading through code isn’t enough for me, I find that I retain concepts much better when I get code under my fingers multiple times. Copying code, running it, and seeing what happens when I do something helps me solidify syntax in my brain. Occasionally, I’ll refactor the code I copied as well to help me become more fluent.
I apply this idea when someone graciously spends time to help me learn a new language. When they show me a piece of code, I delete it and retype it from memory.
Mix Small Projects with Educational Materials
Screencasts, tutorials, and books are indispensable when learning new languages, especially languages that require different ways of thinking. As helpful as they are, I always find that solving problems with the new language helps me level up very quickly.
I found small projects where using Clojure/ClojureScript made sense: a D3.js visualization using ClojureScript instead of JavaScript, tasks written in Clojure that collect and and clean up data for my side projects. The key is to find straightforward projects that are accessible enough to be finished in a short amount of time.
Set a Time Limit
While learning Clojure, I found myself stuck on tooling issues, environment issues, and concepts that don’t seem to make sense in my brain. When I find myself getting frustrated and not making progress, I set a timer for 20 minutes. If I haven’t made any progress, I either deal with it and move on to something new or stop for the day and revisit the issue when I have a clear head or can get help.
I also force myself to set a limit to the amount of time I spend on tooling during my learning sessions. There are nearly infinite ways to improve an editor workflow, but spending an entire learning session on tooling makes me feel unaccomplished and less motivated the next day continue my education. Instead, I spend a little time a few times a week improving my workflow, doing things like researching new tools, learning new editor commands, or customizing my current editor configuration.
In the past, I usually felt overwhelmed and frustrated when learning a new language. Adopting habits that work with my way of learning and tweaking my approach helped me learn Clojure effectively and sustainably.