Can adults learn to code?

tl,dr Yes.

Since becoming more involved with getting kids in to coding recently, I've heard the phrase "Year 8 is too late!" quite a lot and before this week, I would've agreed, mostly. It's harder to learn new skills when you're older, it's a well-known fact. There's a theory of 'brain plasticity' which suggests that children's brains are much more able to learn new things than adults. Who am I to argue with scientists? But what I experienced earlier this week was truly remarkable.

First, some context...

I was asked by Cyfle (pronounced 'cuh-fluh', not 'siffle' as I embarassingly found out) to run a 2 day course called 'Building an iOS App from Start to Finish'. The course would be open to the general public and participants would have zero programming knowledge, although they all knew that they would be learning to code. So although they had no knowledge, they were all willing and eager to learn! (It's also worth noting that over half of the participants were bilingual.)

I'll admit to being skeptical. If you're teaching adults with zero programming ability to write an iOS application, chances are you're thinking you might teach some simple HTML/JS framework which produces something that looks a bit like a native app. The honest truth is that my javascript skills SUCK. Big time. I can get by, but there's no way I'm in any position to teach anyone anything. At this point, I have two choices.

  1. I can turn down the work. I don't want to do this.
  2. Teach complete programming novices how to code in Objective-C.

Oh hell no.

Teach complete novices to code in Objective-C?! Seriously? I must be mad. So I gave it some thought. Before I got started, or even accepted the work, I had to decide if it was even possible to make this a success. The big questions that needed answering were:

  1. Why do experienced developers shy away from learning Objective-C? Are they things that we can overcome?
  2. Am I going to look like an idiot?

So, question 1.

Why do experienced developers shy away from learning Objective-C?

Well that's quite simple really...

It's hard!

I can't overstate that enough. That said, I have to think about why it's so hard. What makes it hard? I think a great majority of it's perceived difficulty is due to how syntacticly unfamilar it is to experienced developers despite being a very idiomatic object-orientated programming language. This isn't something that complete novices will have to compete with. This will be their only exposure to programming in their lives so far. They don't know languages that you and me might consider 'easier' such as Ruby or Python even exist. I think we can overcome this.

Am I going to look like an idiot?

Maybe. Maybe not.

But there's only one way to find out...

In case you hadn't figured it out yet, I agreed to run the course. It would be an interesting experience whatever the outcome.

Day 1

Having arrived and met my participants, I quickly set to find out about them. I had 8 adults between the ages of 30-55(ish) (and all older than me, yes), none of whom had ever coded before but all were comfortably computer literate. They all worked for companies and charities who are looking to build an app or find out whether or not an app is right for them and they all wanted to have a taster of the programming side of things. Great! I had planned for exactly what I got, so no complaints so far.

We jumped head first in to some classic OO programming concepts. Classes, objects, instance variables... the usual stuff. I figured this would be a good place to start. We had a break and then I fired out the question:

What is an object?

Which was followed almost instantly by the response:

An instance of a class.

This had to be a good sign. I felt like this dude.

OH HELLS YES

I had 8 people who were confident with the theory behind (admittedly, the basics) of object-orientated programming. Next, we started to code. The command-line application template in XCode 4.2 was excellent. We could write some simple statements and get the computer outputting stuff to the screen. We started with the basics:

NSLog(@"Hello, world!");  

Oh, wow. We just told the computer to do something, and it did it. No big deal. Except that it was. This was the first successful program that these people had written. So what's next? Do it three times.

NSLog(@"Hello, world!");  
NSLog(@"Hello, world!");  
NSLog(@"Hello, world!");  

Next? Refactor in to a variable:

NSString *message = @"Hello, world!";  
NSLog(message);  
NSLog(message);  
NSLog(message);  

We carried on like this for the rest of the day. Tiny, tiny, iterations of our program. Which slowly got steadily more and more complex. By the end of the day they had all produced something like this.

int number = 3;

if (number >= 0 && number <= 10 && number * number == 9)  
{
    NSLog(@"Congratulations, you found the correct number.");
}

and other examples that made use of for loops, NSDictionary and NSArray. Even better, we even got time to discuss mutability and how it works in this context.

At this point, I'm pretty stoked.

These guys are really getting it. Let's make an app. It won't be a difficult, but just a small app that increases a number on the screen if you press one button, and decreases if you press another. We set up our XCode project, I showed them how to code one button and asked if they could get on and code the other. The majority of them did with very little input. The ones that did struggle were with syntactic issues and not a failure in understanding the underlying concepts. Syntactic fluency in programming comes with practice. So I'm not too worried about that.

As time passed the participants went from strength to strength with 6 of the 8 people who started the course completing it with a fully working calculator application. I may not have scientifically disproved that "year 8 is too late", but it's certainly not as much as a certainty as we had assumed. From now on, when I hear people say "I'm too old to learn to code." I'll be more willing to argue with them.