Posts tagged ‘Python’
Pilot testing the new AP CS definition
Here at the AP CS Advisory Group meeting this weekend, the first five curriculum developers, teachers, and pilot testers of the “Computer Science: Principles” course definition were named.
- Beth Simon of University of California at San Diego will be teaching 900 students (!) in Fall 2010 using the new AP CS definition. She’ll use Alice with the book by Wanda Dann, Steve Cooper, and Randy Pausch. She’s also planning to use Excel. She’s planning to use a peer instruction model.
- Jody Paul will be teaching this class at Metropolitan State College of Denver. His is an open-enrollment school, so he has no control on pre-requisites of students. He’s planning to focus on connecting students’ life experiences with the learning objectives about computing. He is going to use Scratch and visualization tools.
- Larry Snyder of University of Washington, Seattle, is going to create a new course to parallel his successful fluency with information technology course. His new course will be in Python and will have a heavy emphasis on the Web, to relate computing concepts to a computational phenomenon that students care about.
- Dan Garcia is going to continue develop his course on “Beauty, Joy, and Awe of Computer Science.” His course uses a new version of Scratch called “BYOB” for “Build Your Own Blocks.” BYOB-Scratch uses a Lisp-like computational metaphor, e.g., where lists can contain blocks, and a “Run” block can execute a piece of block/data in a list. Dan’s course already hits most of the items in the new AP CS requirements.
- The fifth pilot tester is Tiffany Barnes of University of North Carolina at Charlotte who wasn’t able to attend the meeting, so I can’t report on her plans. (She’s on leave this semester.)
It’s exciting that the five pilot-testers are going in such different directions, which in itself emphasizes the flexibility in the new requirements. The overall curricular definition is up around 70 pages now — there’s a lot of definition to live up to. What happens next with the AP CS depends a lot on these five. God and the devil are both in the details.
Language Choice = f(Number of Copies)
Last night, a user reported a bug in our latest version of JES, the Jython IDE that we use in our Media Computation classes. In cleaning up the code for release, one of the developers renamed the short variable “pict” to “picture”–in all but one spot. The function that broke (with a “name not found” error in the Jython function) is writePictureTo, a really important function for being able to share the images resulting from playing with Media Computation. This was particularly disappointing because this release was a big one (e.g., moving from one-based to zero-based indexing) and was our most careful development efforts (e.g., long testing cycle with careful bug tracking). But at the end, there was a “simple clean-up” that certainly (pshaw!) wasn’t worth re-running the regression tests–or so the developer thought. And now, Version 3.2.1 and 4.2.1 (for zero and one-based indexing in the media functions) will be out later today.
This has got me wondering about the wisdom of developing an application used by hundreds, if not thousands, of students in Python (or Jython). I’ve done other “largish” (defined here, for a non-Systems-oriented CS professor, as “anything that takes more than three days to code”) systems in Python. I built a case library which generated multiple levels of scaffolding from a small set of base case material, called STABLE. Running the STABLE generator was aggravating because it would run for awhile…then hit one of my typos. Over and over, I would delete all the HTML pages generated so far, make the 5 second fix, and start the run all over. It was annoying, but it wasn’t nearly as painful as this bug — requiring everyone who downloaded JES 3.2/4.2 to download it again.
I’m particularly sensitized to this issue after this summer, where I taught workshops (too often) where I literally switched Python<->Java every day. I became aware of the strengths and weaknesses of each for playing around with media. Python is by-far more fun for trying out a new idea, generating a new kind of sound or image effect. But this bug wouldn’t have happened in Java! The compiler would have caught the mis-named variable. I build another “largish” system in Squeak (Swiki), which also would have caught this bug at compile time.
My growing respect for good compilers doesn’t change my attitude about good first languages for students of computing. The first language should be fun, with minimal error messages (even at compile time), with rapid response times and lots of opportunities for feedback. So where does one make the transition, as a student? Why is it important to have good compilers in one place and not in the other?
I am not software engineering researcher, so I haven’t thought about this as deeply as they have. My gut instinct is that your choice of language is a function (at least in part) of the number of copies of the code that will ever exist. If you’re building an application that’s going to live on hundreds, thousands, or millions of boxes, then you have to be very careful — correcting a bug is very expensive. You need a good compiler helping you find mistakes. However, if you’re building an application for the Web, I can see why dynamic, scripting languages make so much sense. They’re fun and flexible (letting you build new features quickly, as Paul Graham describes), and fixing a bug is cheap and easy. If there’s only one copy of the code, it’s as easy as fixing a piece of code for yourself.
First-time programmers should only be writing code for themselves. It should be a fun, personal, engaging experience. They should use programming languages that are flexible and responsive, without a compiler yelling at them. (My students using Java always complain about “DrJava’s yelling at me in yellow!” when the error system highlights the questionable line of code.) But they should also be told in no uncertain terms that they should not believe that they are creating code for others. If they want to produce application software for others, they need to step up to another level of discipline and care in what they do, and that usually means new tools.
I still strongly believe that the first course in computing should not be a course in software engineering. Students should not have to learn the discipline of creating code for others, while just starting to make sense of the big ideas of computing. The first course should be personal, about making code for your expression, your exploration, and your ideas. But when students start building code for others, engineering practice and discipline is required. Just don’t start there.
Media Computation update
Barb and I turned over the final edits to production on our data structures textbook last night. (YAY!) It’s promised in December.
The second edition of the Python book has just now hit the streets. This version is in full color, so it works more like the Java book and less like a grayscale book hinting at multimedia.
I finally got around to fixing up http://www.mediacomputation.org Please do visit and let me know if you can find what you’re looking for there.
I’m off to Kansas City for a Media Computation workshop July 29-31, then an APCS Advisory Board meeting August 1-2, and then five days of teacher workshops (on Media Computation and IPRE) here in Atlanta. It’s going to be an intense 10 days, so I probably won’t be here much in that time.
How high school students start thinking about code
My colleague Amy Bruckman and her student Betsy diSalvo have a really great project going on this summer, called Glitch. Betsy is interested in how African-American males engage with technology and why so few pursue computing as a career. She notes that African-American males play video games more than any other gender-ethnicity demographic groups, and yet are one of the most under-represented groups in computing majors and careers. To address this discrepancy, Betsy and Amy are training a group of African-American teen age boys to be game testers, and in so doing, getting them to engage with how the games they love are built.
Amy and Betsy are teamed up with Dr. Charles Meadows of Morehouse College, who is teaching the teenagers how to program in Alice. Betsy wanted them to see some textual code, too, to get them to see how programs like their games are created. I agreed to teach a few sessions of Alice + Media Computation (like at the Tea Party site) being developed by Barb Ericson, Wanda Dann, and Steve Cooper. That way, they’d be learning a bit of textual code to work with their Alice worlds. I decided to do it with Python, so that there’d be less overhead than Java. (My slides are available, if you’re interested.)
I’ve found it fascinating to work with the Glitch guys. It’s been many years since I’ve taught high school students, and rarely in a situation with a small number of students. I get the chance to see what they’re struggling with, and how they tackle problems. I’m learning a lot about how these students think about code.
They got the idea early on that they can change constants in programs, and things generally keep working, though sometimes in new ways. One of the students took our function to generate a negative of an image and started changing constants, like this:
def negative(picture):
for p in getPixels(picture):
r = getRed(p)
b = getBlue(p)
g = getGreen(p)
#Original: color = makeColor(255-r, 255-g, 255-b)
color = makeColor(20-r, 5-g, 100-b)
setColor(p,color)
The result was really interesting. Because the values for red, green, and blue were clamped at 0, the effect was to posterize the image. Bright colors emerged, and the number of colors were reduced. I don’t think the student who invented this really understood what he was doing. It was a positive outcome that rewarded tinkering, poking-around.
Another one of the students wanted to write a function to make an image completely black. What he wrote was absolutely amazing to me.
def makeBlack(picture):
for p in getPixels(picture):
r = getRed(p)
b = getBlue(p)
g = getGreen(p)
#Original: color = makeColor(255-r, 255-g, 255-b)
color = makeColor(0=r, 0=g, 0=b)
setColor(p,color)
I asked him to explain what he was doing. Here’s how I think he understood his program. He saw the variables r, g, and b as defining a relationship — that r would represent the red channel for the pixel, so changing r would change the pixel’s red value. He saw 0=r as setting the red value to zero. Why didn’t he write “r=0“? He hadn’t quite internalized left-hand side vs. right-hand side. He completely understood that he needed to make a color with red, green, and blue all zero, and he could explain clearly what he wanted his program to do. He just didn’t understand why his program didn’t work. I find it amazing that he had such a clear view of what he wanted and how his program should work.
As a group, I asked them to try to figure out what the right “brightness” value should be, in order to make a grayscale function. Here’s what we started with:
def grayscale(picture):
for p in getPixels(picture):
r = getRed(p)
b = getBlue(p)
g = getGreen(p)
brightness = ???
color = makeColor(brightness,brightness,brightness)
setColor(p,color)
The question is, what goes in the place of “???” Somebody guessed “50” and the others shot him down. That would fill the whole image with the same gray value. They guessed “r” (the red channel value) and we tried that — you get a good grayscale, but too light. Then we tried “b” (the blue channel), and it generates a good-but-dark grayscale. One of the students correctly said, “We want the average of the color parts!” So I replaced the right hand side with (r + g + b)/3, and the students started groaning. “You can do that?!?” Now, I had told them that the right hand side of the equals sign could be any expression, and I had shown them various expressions. What was clear that they hadn’t made the connection that the right hand side of the “brightness” computation could be an expression involving red, green, and blue.
I had lunch once with Randy Pausch, the year that SIGCSE was in St. Louis. He told me, “Variables are easy! You should never have to spend more than 10 minutes on them!” I think he was telling the truth as he saw it — for Carnegie-Mellon University students. Most students that I see as non-CS major freshmen at Georgia Tech, and these high school students, find variables and expressions to have a lot more facets and complexities than I might have guessed. These examples are just pieces of the interesting ways in which they think of variables. If we want to help students to learn to code, we have to spend time to make sure that they get these basic ideas like variables, which to us are “easy,” but aren’t when one is first getting started.
Recent Comments