Ryan Stenhouse

How we learn a language (From my SRC 2012 talk)

I was lucky enough recently to speak at the Scottish Ruby Conference in Edinburgh, this blog post is partially a transcript of my talk.

I’d like to open with a couple of questions, nothing too onerous – hands up if you came to Ruby from another programming language.

Most of the room, when asked, raised their hand to show that Ruby was the 2nd or later programming language that they had learned.

I’m quite opinionated on the subject of languages and language learning, and I’m going to be sharing some of my thoughts with you.

Like many (if not most) of you here, I speak a fair few languages:

  • English
  • Ruby
  • Japanese
  • Javascript
  • French
  • There are more…

Some of them I learned in a classroom, others in front of my computer, or by reading books or listening to mp3s / tapes. I guess most of you learned your languages using one or more of these methods.

I’ll be going into that a bit later.

First though; I’m going to tell you a wee story:

In 2005, I went to Japan for the first time. This was also the first time I learned how to eat food with chopsticks.

I was at a small traditional looking restaurant in Shibuya, not all that far from the train station (can’t remember its name) with a friend. We had a really friendly waiter who had a wicked sense of humour.

I asked him for a fork, he looked at my friend, they shared a look, this moment of inexplicable unspoken communication. Both nodded, he pointed to the chopsticks, wished me ‘good luck’ and left.

So, faced with the choice of:

  1. Eat with Chopsticks

  2. Starve

  3. Eat with fingers

I chose ‘1’. If you’ve ever seen me eat with chopsticks, you’ll see that I do have a rather unique technique.

Necessity drives a lot of what we do. How many of you (hands up again please, sorry), learned Ruby (or another programming language) because you had to for one reason or another, probably due to work?

About a third of the room raised their hands. When the follow up question was asked: “How many of you learned Ruby for fun?”; well over half the room put their hands up.

If you’ve had your hand up at all this afternoon, you’ve already learned another language, sure, it was a comparatively simple computer language rather than a complex beast like a real-live natural language; but the skills you need to acquire to learn either are the same; and the application of those skills is also the same – and I’m here to explain a but more about them today.

Hopefully I’ll be able to make it clear that the problem of learning a natural language isn’t all that dissimilar to learning a programming language, and that the approach to the problems is the defining point, and that by thinking about them a little differently; you can become conversant with reasonable, but not already taxing levels of effort.

I know this, because you’ve done it before.

I’m going to talk about two languages I’ve learned, or rather, I am still learning. They’re quite different from one another, both are from the Far East and have mixed reputations with regard to how difficult they are to learn.

One I studied through immersion, fighting my way against a strange grammar and some very strange idioms. I was forced by necessity to engage with the culture and community supporting the learners of the language and found it invaluable.

The other also had a strange grammar and its own idiomatic strangeness that to an outsider like me were almost incomprehensible. I studied this same way I was taught French in High School – from textbooks and other examples, online media, video presentations and even podcasts.

Turns out that kind of learning doesn’t work out too well for me; especially when it makes me flash back to horrible French lessons form a disinterested teacher.

To this day, the phrase “écoutez et répétez” sends a small shudder right down my spine.

We were using first edition Tricolore textbooks from the 1980s and listening to tapes which were just as old. Never once since have I ever felt the need to ask: “ou est la discotheque” in anger.

I think that ‘repeat from a tape’ learning detaches you from the living heart of a language and the associated culture and brings in an artificial ‘other’ component – the ‘textbook’ and the idea that a textbook can tell you everything you need to know about a language just be reading aloud or writing phrases over and over.

You wouldn’t sit with the Pickaxe open in front of you and read it from cover to cover without having a computer to hand to type the Ruby into, right? It’s kinda the same thing.

The languages I specifically want to talk with you about today are Ruby and Japanese, and my experiences with learning and continuing to learn both.

First, a wee bit of my history with these two languages:

I made my first attempt at learning Japanese from the summer of 2002 until May 2005, when I visited Japan for the first time. Since it was a ‘real’ language, I approached learning Japanese the same way I was taught French in school. You know, the illusion that constant droning repetition leads to understanding.

I thought it went well, until I found myself in Tokyo and unable to understand a word anyone was saying, including my friend and guide for some of the trip. I didn’t know Japanese folks spoke so fast in real life, and I certainly hadn’t considered dialects of the language as being significantly different. I was an idiot, but I was also learning in a bubble – these things didn’t occur to me.

My friend was from Osaka and spoke kansai-ben, a rather different animal to the kyōtsūgo (Common Language based on Tokyo’s dialect of Japanese) I had learned.

A while after I got back from Japan, I trained as a Teacher of English as a Foreign Language. I had a fantastic instructor, who managed to install a need for immersion, rather than rote being the best way to learn a language. She then processed for an entire day to instruct the class in Turkish; was very informative and quite good fun.

Learning Ruby as an entirely different animal. I’d played with it for a bit before landing my first real Ruby job at PCCL in 2007 and was thrown right in at the deep-end.

I needed to get up to speed quickly, so immersed myself in the code of the application, looking up bits I didn’t understand or couldn’t figure out in The Pickaxe; the reference section alone is worth buying the book for..My background in various disciplines of programming languages helped greatly, and I was able to draw on that experience to figure out what was going on and where.

Everything I head already learned from playing around with Ruby before crystallised and I was productive in a number of weeks and fluent in a matter of months, with a few trips onto IRC and onto mailing lists to get questions answered, not to mention the wonderful support my colleagues offered at the time.

It was about this time that I started picking up learning Japanese again, and radically changed my approach. That’s what I’m here to talk about. Immersive learning was great for me, but I wondered if I could approach things a bit more like learning to write a programming language.

Here’s what I mean:

We’re fantastic problem solvers. We have to be, it’s part of our craft.

Andy Hunt of the Pragmatic Programmers says it better than I could in his book “Pragmatic Thinking and Learning: Refactor your wetware”:

Programming is all about problem solving. It requires creativity, ingenuity, and invention.

Andy goes on to say:

… we need to look at the really hard problems of social interaction in and between teams and even at the harder issues of just plain old thinking. No project is an island; software can’t be built or perform in isolation.

And further to say:

Programmers have to learn constantly—not just the stereotypical new technologies but also the problem domain of the application, the whims of the user community, the quirks of their teammates, the shifting sands of the industry, and the evolving characteristics of the project itself as it is built. We have to learn—and relearn— constantly. Then we have to apply this learning to the daily barrage of both old and new problems.

It sounds easy enough in principle perhaps, but learning, critical thinking, creativity, and invention—all those mind-expanding skills—are all up to you. You don’t get taught; you have to learn. We tend to look at the teacher/learner relationship the wrong way around: it’s not that the teacher teaches; it’s that the student learns. The learning is always up to you.

If you haven’t read this book yet, go and buy it now. Well, not now now. After! I wish I had read it years ago.

Why not treat learning to speak another language like a software problem?

I say you’ve all learned a language before – I’m deliberately not making a distinction between a natural language and a computer one.

There’s a good software engineering principle: “the separation of concerns”.

We create a set of concerns as abstractions from a solution, relevant to the problem we’re currently trying to solve. That’s how we work, and who doesnt like a bit of abstraction – we’re Rubyists!

We can do that with learning how to speak a language. We do that any way when we’re learning a new programming language.

An Example

Consider the following snippets:

  $strings = array('I','am','a','programmer','see');
  foreach($strings as $value) {
  strings = ['I','am','a','programmer','see']
  strings.each do |value|
    puts value
  strings = ['I','am','a','programmer','see']
  for value in strings
      print value

You look at these three code examples and know they’re equivalent. You don’t even necessarily need to be familiar with more than one of these languages to be able to extrapolate the meaning.

How about these three?

  1. Balle
  2. Ball
  3. ボール

Again, you can probably guess that all three of these mean “ball”.

And finally, how about these three?

  class Ball
    def bounce; end
   ball = Ball.new

These are still all balls. They all have the same meaning, explained in a different language; why can’t we treat them the same? They all represent the same notion of the abstraction of an idea, and we’re Rubyists – we love abstraction!

Bringing it together

When you’re learning a new language, you pick up the vocabulary first. You look for things that are familiar to you based on your experience, you ask people. Even if you just hold up a ball and point to it you can be told that it’s “une balle”.

Your Vocabulary is the set of words within a language that are familiar to that person.A grammar is the set of structural rules that govern the composition of a language.

That’s how you’re able to pick up a new programming language quite quickly – the vocabulary is largely known. The main differences for programming languages are to do with the grammar.

You engage with the community and consult resources on your own terms to study the grammar.

The difference is a mental one – you think one is hard because you’re more experienced with the other. The same analytical approach you take to learning another programming language can be applied.

Think of it as a communication problem:

  1. A programming language is how you speak to a computer.
  2. Learning how to speak to a person is the same problem.

Natural languages have at least three components, how they’re read, how they’re written and how they’re spoken.

You can learn to speak a natural language without learning to read and write it. 
It’s a great first step; since it builds vocabulary.

For now, to memorise the sounds, just jot down your own phonetic version of what you’re wanting to say.

You can worry about writing later. You can iterate later.

Seek out other learners of your language, and hang out on mailing lists, Stack Exchange and IRC channels. Harass folks on Skype to practice – all the tools you’d use to learn a programming language.

You’re good at this! You must be, you’ve already learned other languages.