Sunday, October 4, 2015

The great experiment: teaching my son to program (part I)

There are many reasons why I want to teach my kids to program.  For starters, it's just great fun. What could be a better present that to teach your children a new way to enjoy themselves?  When I program I sometimes feel like a novelist creating new worlds; sometimes like a carpenter using old techniques with new tools; sometimes like an architect free to implement my vision under the constraints of time, budget, physics and the almighty customer; sometimes like a detective collecting data to uncover who killed the pointer.  And all the time I'm an engineer - a problem solver.  In 2015, I believe, everyone should know something about programming.  Lawyers, and artists; doctors and carpenters; pilots and salesmen.  Everywhere around us are systems that someone else programmed, and understanding something about how these "things" work is empowering. Improving on these "things" can be life-changing.
Joy comes from quenching one's thirst to understand, to imagine and to create.  And so this skill is more than a utilitarian skill - it can be a lifelong hobby through which the kids will express their artistic sides.
Or not :-)
I don't know how this "experiment" will end: will my bubble burst, or will I help them open the gates of a new world?  At least, I hope, we will bond.  If only just a bit.

My daughter wasn't interested in this "project" of mine.
I couldn't entice her with promises of discovering bright new worlds. Bummer.  It took me a couple of weeks to recover from this arrow to the heart.
Alas, my son, who is younger and spends enough hours of the day playing games on the net, was more amenable.  So off we went.
To his room, that is, to crank up the old IDE.

Roll back a few weeks earlier: I was in the fantasizing stage at that time.  First thing I did was choose a language.  I wanted a high-level language to abstract away the complexities of the underlying hardware.  A language that has great development tools, and a large set of libraries pre-integrated in the development environment.  In other words, it should be intuitive and with minimum friction so that we can get off and going with no resistance.  C# was the obvious choice for me - it meets all my criteria and has a free world-class IDE provided by Microsoft.

I searched for online C# learning resources, but quickly gave up on that direction.  None of the sites I found provided an environment that is hands-on, educational, and captivating to a 13 year old with a short span of attention.
So it is up to me.  I have one chance, I know.  Get it wrong from the out-start, and I will lose his interest for a long time.
My son is a youtub'er and an online gamer fond of gadgets and is not easily impressed by simple graphics.  It took me a few drives to work and back, to come up with an idea (these long drives are good for catching up on podcasts, but also for reflection).    But before I hit this idea I had a couple of failures. I first tried interesting him in building a site on Wix.  He thought it was "cool", but it didn't stick.  Mostly it was my fault: I didn't plan ahead and I thought that once I show him the tools, he will pick it up from there - motivated by his endless curiosity.  But, no, that didn't happen.  He was much more "curious" about watching some youtube video :-(  And this was OK by me, because really, Wix is not programming. Next I tried interesting him in replicating the Mine Craft console interface.  I often see my son using the Mine Craft console and he commands it better that I know that Linux Bash shell. We hacked up in a single session, a simple command-line-interface console application which accepted user input and executed simple commands such as the 'log-in' command with (fake) user and password; 'quit' command to exit the application, and error messages.  I showed him how to use the Console object for basic I/O and taught him the basics of the "if" statement and string comparison.   I stuck to a bare-bones approach: use only what you need and use it "leanly" - no fluffy stuff to add confusion.  So, for example, when we used Console.WriteLine - well, it was just a way to print characters to the screen.  No explanation about classes, objects, or methods.
I never use C# myself, which is fortunate for this experiment. Each time I wasn't sure how to do something, we googled it.  Using the experiences and advice of others through google is a great lesson.

And then came the flop.
My son's attention was wavering and we've achieved enough for this first session.  So I called it quits and gave him some ideas on how he could make a few incremental changes.  And then I left him, hoping that I did enough to pique his curiosity and that he will continue alone later.  That "later" never came.  In the coming couple of weeks I tried to get him to continue alone a few times, but youtube and Mine Craft were more interesting.  But I saw the "spark" of curiosity and some excitement, and that was enough to keep me motivated.  He said he now understands how the Mine Craft command line works.

I learned two things from that experience.  First, this is going to be "our" project.  There are too many distractions luring him, and I'll have to sit with him through several sessions before trying again to invite him to work by himself.  And this is fine because I enjoyed our session.  Second, I really have to choose an interesting project, which also has a lot of room for new features.

The next project will be a game.


No comments:

Post a Comment