Friday, April 22, 2011

Programming--idealized education

J has just completed his latest Python program--one that lists all the prime factors of whatever number you input. He's really into the programming, and this has got me thinking about how ideally suited basic, interactive programming is to learning.

-It provides immediate feedback: as soon as you run your code you see whether it works, and if not, where the problems are.
-Learning is active: it's still up to you to figure out how to fix the problems.
-Standards are high: Computer programming is unforgiving--even of tiny errors. The program simply won't run if you make any mistakes.
-In particular, you must express things clearly and logically, without any syntax mistakes, missing steps, inconsistencies, or undefined terms.
-There's consistent, effective reinforcement: when you get it right, the gratification is immediate and intrinsic (your program works!)

Can't we make all learning this way--and stop saying it's bad to have high standards, unforgiving feedback, and the ever-present authority of an absolute truth that won't let you get away with anything?

J, in particular, is engrossed by this environment. Here's his prime factors program:

def div():
number = input('Enter the number: ')
division = 2
factor = 1
while division < number + 1:
if number/factor % division == 0:
print division
factor = factor * division
division = division + 1
while 1==1:


gasstationwithoutpumps said...

I agree that programming is an excellent model for effective use of technology to aid learning, and that programming is an excellent way to improve one's ability to decompose problems into smaller ones, where both the big picture and the tiny details matter.

I recommend that you get your son a good tutorial book on programming in Python, as the example program you show, while ok for a first attempt, is not particularly well written.

He might also be interested in the Euler Project, which I've commented on at

Katharine Beals said...

Wow, GWP, I'm speechless. But speaking as his mother, I think J did an excellent job on his first attempt, and that his program does what really matters for our purposes: it captures, quite efficiently, the mathematical concepts and logic behind prime factorization. I was truly impressed, even moved (I couldn't have done nearly as well at his age and level of experience), and I wouldn't ask for more at this stage.

I have ordered a programing book that a friend recommended (Python Programming for the Absolute Beginner), but not to show J the fine details of programming style, but for as a source of programming exercises. I will report back on how we use it later on.

While you're probably more of a Constructivist than I am in general, I'm perhaps more of a Constructivist than you are when it comes to programming. I prefer that J discover on his own, via programming exercises, the virtues of those aspects of "well written" programming that truly matter, rather than teaching them to him explicitly.

gasstationwithoutpumps said...

I wrote a long response to your reply a few hours ago, but blogger threw it away.
Let's see if blogger is still refusing comments.

gasstationwithoutpumps said...

OK, I'll try again.

I can't remember my son's first programs, but they were probably of similar quality. I praised him for his accomplishments and only later started adding suggestions for better ways to do things. You are, of course, right to focus on the positive (at least initially).

There is tension in any creative field with high technical demands (music, dance, programming, poetry, … ) about stifling creativity and desire versus correcting technical flaws. The right balance varies from student to student and from time to time within a single student. I was thinking of a somewhat older, more advanced student in my previous remark.

I still suggest getting a good tutorial book, as the best way to break bad habits (in programming or anything) is not to form the bad habits in the first place.