Trouble At Code School
Written by Mike James   
Friday, 07 December 2012

Computer Science Education Week is a good time to consider how things are going in the teaching of programming. The verdict however is more a "what are these guys doing" rather than a "well done". What is wrong with code school?

Being brought up in the first era of the home computer I can't really understand how the coding skill got lost. Back in the 1980s we were all keen to learn to program and even schools seemed to be taking on the task of teaching kids to program. It wasn't a time of revolution because it just seemed obvious that learning to program was an essential skill for the world we found ourselves in. It was inevitable.

Then things started to go wrong.

Schools diluted programming with spreadsheet and word processor classes. This didn't seem terrible at the time because they were valid technical topics and why not broaden the outlook. What few realized was that this was the start of the pushing of advanced technology out of the curriculum. With teachers unable or unwilling to tackle difficult subjects, and with computers becoming a commodity item, the need to program seemed to be unnecessary and so the enthusiasm and the determination to teach it and learn it seemed to dissipate.

Many of us involved in programming and computers didn't really notice the change. To us it was so obvious that programming and computing was an essential skill that we just thought it was still being taught. Imagine the shock then that in recent months a campaign to spread the knowledge has sprung up with people like Mayor Bloomberg pledging to learn how to code and organizations such as Khan Academy, Coursera, Udacity and Code Academy getting serious amounts of money to teach coding skills.

I wouldn't say that code school has become cool, but it certainly is on the way to where it belongs.

And yet we seem to be doing it all wrong.

I have helped a few new programmers get into programming via a number of the recent online courses and at each one I have been shocked to discover the barbarity of the teaching methods. When asked to help with some problem of other I have been literally gasping for air trying to explain why the approach is not only wrong but damaging to the student. I found myself saying over and over and over again - "It's not your fault - it's theirs!"

So if you have signed up to any of the well known courses to learn to code in Python or some other language and found it hard, don't beat yourself up because you really didn't stand much of a chance.

Let's see why.

You really do need an expert to teach almost any topic, but for programming there are some additional problems.  The experts in programming are usually even more expert in some other subject  - this is where the computer science gets into Computer Science Education Week. From the elevated point of view of an academic computer scientist, programming is a trivial matter that gets you on to the more interesting stuff.

It is a bit like asking a master juggler and acrobat for lessons in standing up - they do it but they have long forgotten how and can't even understand the mind set of anyone who can't.

Programming is a mental skill that you have to acquire and it is difficult.

I have written about this many times before and I'm not going to repeat the ideas in detail. The skill of programming is in translating a dynamic algorithm into a static text. Before you can program you don't see the text or the code of a program as being equivalent to what a computer does. You don't see the flow of control, the conditionals and the loops - you just see a description or a definition. You don't see the exact correspondence between the text and the soft machine that text creates. 

As Commander Spock would say after pointing his tricorder at a program:

It's text, Captain, but not text as we know it.

It takes time to learn how to see an exact algorithm for a problem, and even more time to see how to convert this into static text and learn all of the skills involved in debugging and optimizing the way things work. As well as being time-consuming, it isn't easy to learn.

All of the code schools I've encountered take the approach of showing how the syntax of the language works with the expectation that the deeper semantics will follow.  So you are shown a few instructions, a loop and before you know where you are you are on to difficult algorithms - reverse this string, discover if this a palindrome, how many occurrences of this substring and so on. These are difficult algorithms and the fact that they are introduced so early makes it difficult for the beginner who is still struggling with the task of translating even simple algorithms into text.

The first step in programming isn't thinking up complex algorithms, it is in seeing the connection between simple algorithms and the equivalent text.

Why do code schools move on so quickly to difficult algorithms?

Because the creators of the course really don't see any difficulty in implementing simple algorithms.

It is as if you were being taught arithmetic for the first time by a professor of algebra who introduces 1+2=3 and then expects you to solve a quadratic equation in symbols because arithmetic is so simple it isn't a problem at all.

I have been confronted by questions set to supposedly coding beginners that I have solved for real perhaps once in a long time of programming and sometimes never. They often make me stop and think about the best way to do the job - and I am an experienced programmer.

What should happen is that the basics of the flow of control and expressions should be drummed in with simple, but not boring, examples until the student dreams in code.

You need to be exposed to different types of conditional, you need to experience the sum loop, the product loop, and the idea of a conditional loop versus an enumeration loop. You need to master nesting and composition of the flow of control and much more that is simply taken for granted in these "beginners courses".

At this point, and only at this point, can you afford the luxury of moving to the more abstract adventures in algorithms.

A similar problem arises with the attempt to explain the inner workings of the language or the machine at the same time as teaching the language. For example, one course goes into great detail about the stack and the way that this is used in the execution of the program. This is, without doubt, something that all programmers need to master eventually - but not when they are just trying to master the art of relating dynamic processes to static text. This can wait, along with the distinction between value and reference semantics, recursion and yes, objects. You can't understand any of these things until you have mastered a foundational skill - that of seeing the way a static text is related to an activity.

If the focus on algorithms and "how it works" places semantics too much to the fore we also have the opposite problem of syntax ruling the roost.

When I taught programming classes, any student who offered up a program that wouldn't run because of a simple syntax error but who had otherwise produced code that was semantically correct got full marks.

This is not the experience of the modern code school student.

I have been asked to help students who were frustrated to the point of tears to "get their program running". Often when I looked at the program it was substantially correct except for a comma or a semi-colon missing or in the wrong place. I could tell them that they need not worry as they had got it right apart from a pesky comma - a small thing. And yet the homework marking couldn't even begin with that missing comma.

This is the programming equivalent of solving a complex math problem but getting it marked completely wrong because you made a mistake in the arithmetic.

You might argue that a programmer who doesn't understand error messages well enough to correct syntax is no programmer - and I would agree. However, when you are learning to program you really don't think that what you are doing is correct. To sort out even a simple syntax error in a program requires a belief in being right. You have to have the "It's not my fault but the machine's" sort of attitude to read the error message, to try to understand it (error messages are always in the language of the skilled programmer) and then to act on the information without introducing some other trivial error along the way.

Programming is more than just the correct placement of commas and matters of syntax.

If you add into to the mix the simple fact that most of the beginner programmers are working alone and really don't know what to expect or what to value as part of the skill, then you begin to see that there is a lot of trouble at code school.

So if you have given up on a course of learning to program, don't feel too bad - it is more likely the course that failed, not you.

Related Articles

A Better Way To Program

MOOCs Fail Students With Dark Age Methods

Programming - A Life Long Challenge

Teach Concepts Not Just Code

Raspberry Pi or Programming - What shall we teach the children?

Lessons From Teaching Python Online

Khan Academy Launches New Introductory Computer Science Curriculum


To be informed about new articles on I Programmer, install the I Programmer Toolbar, subscribe to the RSS feed, follow us on, Twitter, Facebook, Google+ or Linkedin,  or sign up for our weekly newsletter.




raspberry pi books



or email your comment to:

Last Updated ( Wednesday, 26 December 2012 )