[plt-scheme] 2htdp/image questions

From: Stephen Bloch (sbloch at adelphi.edu)
Date: Tue Apr 20 22:33:55 EDT 2010

> When I arrived at NEU, the first-year staff was teaching just these  
> kinds of things (they used to do it in C++, then in Java). The  
> claim that novice programmers understand
>  -- the idea of getting a Python scrip to run
>  -- structures as a data (pixels)
>  -- 2-dim arrays (images)
>  -- parameterized for loops
>  -- nested for loops
> all in one week is ludicrous

Yes, it is... but they can be given sample code that uses all those  
things, and copy it, and tweak various parts of the code until it (a)  
compiles without error, and (b) does something interesting.  And the  
results carry visual impact.  If you mistakenly write a for-loop with  
two variables marching in lockstep rather than two nested for-loops,  
it shows up visually as a diagonal line rather than a full picture (I  
know, I did this last week!)

What I contemplate isn't quite the same approach.  I envision giving  
students "map-image" around the time they see structs (possibly a  
little earlier, with prewritten color->color maps and the promise  
"once you understand structs, you can write your own").  Perhaps,  
even earlier, I could give them a version that takes in three  
functions -- red, green, and blue -- each of which takes in the red,  
green, and blue components of the old picture as separate  
parameters.  This doesn't introduce loops or 2D arrays: all that  
stuff is hidden inside map-image and build-image.  The only "black  
magic" is map-image itself, which is in a sense no more magical than +.

> If you do wish to experiment with such loops, I recommend a  
> Universe-like interface so that the function is more a description  
> of an interaction -- like big-bang and universe -- rather than a  
> map/for-each like construction.

I don't have a clear idea what that would look like.  A little more  

> I like this idea a lot because DrScheme already supports this and  
> has so for many years. When Pythonistas show off nested for-loops,  
> show off the insertion of images into the IDE; show off that images  
> are first-class values and have their own basic arithmetic, just  
> use the docs; and if you know of basic operations that you'd like,  
> propose them and we will add them. I like Noise and perhaps we  
> should add EdgeSharpening, too.

But why do I (or my students) have to go through a feature-request  
process to get additional operations, rather than having an easy way  
to write them ourselves?

If you're trying to show that a Scheme approach is better than a  
Python approach, it's not enough to do some things that Python can't;  
you have to do everything Python can PLUS some things that it can't.   
Otherwise the Pythonistas will simply say "but why would somebody  
want to do that, when they could be doing something useful and cool  
like this?"


Posted on the users mailing list.