This is an old blog post I started writing about a month ago but never got a chance to finish it. I'm not sure I agree with everything I've said in it but will post it here and hopefully build on it at a later date.
Those who can't do, teach. Those who can't teach, teach P.E.
Not that I ever agreed with this statement (the first half of it anyway; I had some pretty dire P.E. teachers), but when put in the context of programming, never has a more untrue phrase been uttered. When I refer to programming in this post, I'm talking about the process of solving a problem by writing code, not software development in its wider context.
My previous two posts have been comments/rants on the state of education and some school's totally inability to teach children how to program. This post seeks to actually provide some constructive ideas on what could be done about it by looking at how programming can be 'taught'. Ask any Computer Science undergraduate "How did you get in to programming?", and I guarantee that a tiny, tiny, minority will say "I learnt x language at school". Those that do say that, will even more rarely have come from a comprehensive school background.
It's all very well to say we're going to address this, but 'coding' isn't one skill that can be taught. It's a combination of skills ranging from critical thinking, problem solving and sometimes just a bit of dumb luck. Let's assume that we have a class of children, all of whom are fairly bright and posess good problem solving skills and all have an active interest in learning to code. I realise this is a massive assumption, but you have to start somewhere, right? What next?
Starting from nothing, it's often very tempting to dive in to 'scripting'. In other words, writing a set of commands in any language, executed one after another to achieve a task, like this:
x = 10 x + 100 output x => 110
Do line 1, line 2, line 3, get line 4.... etc.
This is the easiest type of coding to teach and the easiest to learn, despite this type of code being used almost never in practice. Unless you're an über-hipster writing all your code in some snazzy functional languauge, the majority of code these days is written in Object-Orientated Languages (OO) such as Java, Ruby, Objective-C and sometimes PHP.
I spent a lot of time at university discussing the pros and cons of teaching OOP to university-age students first instead of teaching them to script first and we largely agreed that using an 'objects first' approach was generally a good thing, especially for the 18+ age group. Although this conclusion wasn't reached by all people in this group. I however, saw no reason why this should not be extended to younger kids. Explain coding to them as a way of expressing 'things' as code, and you might be on to something.
Explain that we can create templates, take a car for example. All cars have a set of attributes, these attributes are the same, but their values are often different. Cars can also all do the same set of things: open the boot, get spray painted, go forward, but how they do it depends on their individual attributes.
class Car var make var model var colour var no_of_doors function paint(new_colour) colour = new_colour end end
car = new Car car.make = 'Nissan' car.model = 'Note' car.colour = 'Blue' car.no_of_doors = 5 car.paint('Orange') car.colour => 'Orange'
This may all seem very obvious, but to someone just learning how to program, this is a totally different thought process than the first example of 'scripting'. You cannot expect someone who has grasped the ideas in the first example to automatically be able to understand the ideas presented in the second and third. However, those are the skills that are really used day-to-day by most programmers. So why would we teach kids anything else?