Categories
Family

Learning to Program

The boy had his first experience with writing his own program today and learned about the time honored tradition of debugging.

The boy’s favorite Christmas present is his laptop. It’s not a toy laptop loaded with educational games. It’s the real deal laptop, with a 64-bit Intel processor and 150GB of disk space. Size wise, it’s a netbook so it’s just right for him to set on his lap and peck away at. Best of all, it has Ubuntu installed on it.

The only thing I don’t like about it is the Unity UI. Bleck. But then, I’m not a big fan of UI’s like that. Extended Linux exposure will do that to a user.

The reason he got that kind of rig is because of his desire to learn to program. It’s hard to justify anything else for a kid other than a Linux box since tools, debuggers, editors, IDE’s and any language the prospective programmer could possibly want to work worth are readily available at no charge. If this machine had not been available I’d have converted some other machine, probably a chromebook, as I saw fit.

So he’s enthusiastically resumed his programming activities. In addition to the laptop, he received a “programming for kids” book on python. I was somewhat amused to see that the book’s approach was similar to my own. Namely, introduce him to the language and so forth and build up his ability to write programs.

I’ve come to realize this is a completely inappropriate way to teach a kid like the boy. He needs to see a program actually do something. He doesn’t care about variables and tuples and functions or object-oriented and classes and constructors or closures. He wants to see a ball bounce on a screen.

The book has a couple of simple games it helps the prospective programmer write. It takes the approach of building up the knowledge bit-by-bit until there’s a functionally complete program. Naturally, the boy skipped all that and went right to the part where the whole program is laid out. It’s a “bounce” program, a simple version of the game “Pong.”

I’ll admit to not initially being thrilled with his approach. But, there are plenty of programmers out there that have cut there teeth by reading code and learning how it worked that way. There’s no reason the boy can’t be one of those if he chooses. Most importantly, he was willing to work through it. He did try to see if I’d be willing copy it for him, since I “could do it faster.” I scoffed at the notion though, “I can’t learn how to program for you.”

I did have an “I told you so.” After he’d started writing the code, I told him he would have to debug the program. First, there were bound to be typos in his code and those would cause syntax errors he’d have to work through. Then, there would likely be some lines he missed, or mistyped so the program would fail at strange points. Thankfully, there was only 80 lines of code or so, so debugging it wouldn’t be to difficult a task.

Forty-five minutes later, he’d finished typing it and tried to run it. It puked.

So I helped him fix that mistake. “Do you think it will run this time?” he asked hopefully.

“No.”

And it didn’t. It didn’t run on the third try either. Or the fourth. Or the fifth.

To his credit, the boy maintained his patience. It was obvious he was in that excited state a programmer attains when their program is about to ready to take flight. It maintained his focus.

After we fixed the syntax errors, we finally got a screen to pop up. But it still wasn’t running. Once more, we slowly brought his little program to life. First a paddle appeared on the bottom of the screen. Then a ball appeared above it. Shortly after that, the ball started bouncing around and the game was working.

Through all of it, I tried to explain what was wrong so he’d learn something for the next time. For many of the errors, he’d have needed a better understanding of programming to solve. Regardless of whatever I tried to offer him though, his main motivation was to see it run.

When finally it worked, the boy was beside himself with joy. Literally, a smile from ear to ear. Here was a game that he had “created” and written on his computer that he could actually sit and play.

Since then, he’s gone back and started trying to do other things. Last I saw, he was trying to draw circles on the screen. Hopefully this little success breeds more. Perhaps the thing to look for is a book with various programs for him to copy and play with.

The main thing is he’s off an running.

Leave a Reply

Your email address will not be published. Required fields are marked *