Interim Report: Teaching Programming to Non-Programmers, Week 4
Several weeks ago, a crazy idea popped into my head: why don't I teach programming to my family? Here are the list of characters:
G: my wife, a very gifted artistic person. She uses Facebook, but struggles with anything more complicated. She's convinced the computer is out to get her.
E: my stepson, a graduate of Fashion Institute of Technology. He's used computers for Adobe Photoshop, but not much more.
W: my stepson, a year of college. He has a Facebook page and understands a little about how to use a web browser, but nothing more.
I presented the idea to them like this...
"If you want, I'll teach you programming. But you'll have to take this seriously. Seriously, as in 6 hours a day. The upside is that, at the end of six months, you'll be able to get a good-paying job."
Where did six months come from? As an old Dilbert cartoon quipped, "A doctor with a flashlight will show you..." I have no idea how long this will take, but figured that should be sufficient. Plus, it sounded scary, and I only wanted them to sign up if they were up for a big commitment.
For the language. I could have used ColdFusion, Java, Python -- even JavaScript, but I chose Ruby. Why?
- Ruby is a pure OO language -- I wanted them to learn OO right from the start.
- Ruby is very consistent -- important when you're learning something.
- Ruby will lead us into Ruby on Rails -- so that I can meet my promise that going through this would lead them to a high-paying job.
This is a report after four weeks. First, the synopsis...
The first 2 days we learned our way around HTML. Obviously, we couldn't get deeply into HTML, but we did manage to cover all the basic tags (including forms).
I was anxious to get started on real programming, so we set HTML aside for a bit and plunged into Ruby. I confess I did not have them write a Hello, World program. Instead, we started with the idea of variables and data types. We concentrated on built-in Ruby classes: arrays, hashes (called structs, maps, dictionaries, etc. in other languages), arrays, Booleans, numbers, and strings.
After 4 days of lots of exercises and explorations, they had a good sense that variables were name/value pairs and that they could be simple (numbers, strings, Booleans) or complex (hashes and arrays). However, I made a couple of errors that made learning harder than it needed to be.
First, I inadvertently treated these data types as though they were special, somehow. That became obvious later, when we began creating our own classes. Classes are user-defined data types -- and, in Ruby, have the same first-class status that the built-in data types have. But they were so used to thinking of data types as Booleans, numbers, strings, etc., that it took them much longer to really grasp that everything in Ruby is an object.
My other mistake was using shortcuts. Again, I didn't realize I was doing this. Here, for example, is how I told them to create a new array:
my_array = []
And here was creating a hash:
my_hash = {}
A string?
my_string = "Hello"
But, in Ruby, that's a shortcut. These variables are nothing more than instances of classes -- the Array class in the first case and the Hash class in the second. How do you instantiate classes in Ruby?
my_object = ClassName.new
Had I followed that pattern (as I should) I would have taught them...
my_array = Array.new my_hash = Hash.new my_String = String.new( "Hello" )
Of course no one codes that way -- but that would have been the way to teach. Had I taught it that way, OO would have seemed completely natural and it would have given them the reassurance that everything is completely consistent in Ruby, which it is. Instead, I needlessly confused them. Now, we'll have to do some more work to cement the notion that all variables are objects and that all objects are instances of a class and that no class has any higher priority than another. The syntactic sugar of shortcuts doesn't alter their fundamental nature.
With that mea culpa out of the way, how did they do?
I think amazingly well. My wife, who I thought would have a terrible time of things, picked up on things on a much deeper level than I thought possible with so little exposure. W is like a sponge, absorbing knowledge. After gamely trying it for two weeks, E threw in the towel, deciding that programming just wasn't for him.
This has been a pretty great experience for me. I want to be an excellent teacher -- and teaching non-programmers to think like programmers exercises (and builds) those skills very well. I think my initial six-month estimate was too pessimistic. I think four may be more accurate. Having covered the basics of programming with Ruby, we're ready to move on to Ruby on Rails. This time, I'm going to be careful not to show them any shortcuts while they're learning.
If you're interested in this experiment, I'll update again in a few weeks and let you know how they're faring with Rails!


As for the time scale, I think an hour a day for two years would be more realistic. Lucky for me my kids are young.