Ask Mike: How do you learn a new programming language?

I found myself sitting on a couch the other night explaining to one of my good friends how to learn a programming language. His background was in computer engineering; most of his experience, which was scarce to begin with, was focused on low-level C-like languages.

So, here my friend sits trying to learn a language that is totally different from C, C++, and Java: Ruby. Ruby was my first choice because it illustrates a fundamental learning concept to a language: syntax. In Ruby, we see a lot of unique conventions, short hand notations, and other syntactic sugars and that seems to be the biggest hurdle in learning a language for me.

So here’s my list of concepts and information I seek when I’m treading unknown soils:

  1. Define a class, instantiate it, and make it do something
    • This exercise will give you the opportunity to toy with inheritance, class vs. instance methods, public and private scope, and optionally instance-specific functions like constructors and destructors.
  2. Find an article on “ten neat tricks to ” … or .. “ten things I wished I knew about
    • Explore why others like this language… What is cool to them about it? Do these tricks show you anything about the language that the book(s) or tutorial(s) you’re following do or don’t do?
  3. Read about the language data types
    • Are the data types what you’d expect to see? Do floats auto-magically grow? Are strings immutable? Sometimes by looking at the data types you’ll see some interesting features of a language. For example, in Ruby you can take an integer and call methods on it like .days.from_now (5.days_from_now).
  4. Find an article highlighting the ten worst things about the new language
    • Yup. Understanding the language’s perceived weaknesses is very important. In Ruby, the MRI interpreter supports green threads — this sucks in some cases. But along with the criticism often comes a solution. For the case of parallel threads, using the jRuby interpreter solves that issue by supporting OS-level threads.
  5. Code something fun
    • For my friend, he is building a small BlackJack dealer simulator. Perfect. The important thing here is to pick an idea that you can articulate well, understand how you’d theoretically build it, and would enjoy spending time working on.
  6. Optional: Go read some “Why I Switched from Lang 1 to Lang 2 ” or ” Lang 1 to Lang 2 side by side ” articles.