Posts tagged ‘Python’
My Blog@CACM post for this month is on JES, the Jython Environment for Students, which at 14 years old and over 10,000 downloads, is probably one of the oldest, most used, and (by some definition) most successful pedagogical Python IDE’s.
The SIGCSE Members list recently had a discussion about moving from Python 2 to Python 3. Here’s a description of differences. Some writers asked about MediaComp. With respect to the Media Computation libraries, one wrote:
I’m sad about this one, because we use and like this textbook, but I think it’s time to move to Python 3. Is there a compatible library providing the API used in the text?
Short answer: No. There are no compatible Media Computation libraries for CPython 2 or 3.
We keep trying. The latest attempt to build Media Computation libraries in CPython is here: https://github.com/sportsracer48/mediapy. It doesn’t work on all platforms yet, e.g., I can’t get it to load on MacOS.
We have yet to find a set of libraries in Python that work cross-platform identically for sample-level manipulations of sounds. For example, PyGame’s mixer object doesn’t work exactly the same on all platforms (e.g., sampling rates aren’t handled the same on all platforms, so the same code plays different speed output on different platforms). I can do pixel-level manipulations using PIL. We have not yet tried to find libraries from frame manipulations of video (as individual images). I have just downloaded the relevant libraries for Python 3 and plan to explore in the future, but since we can’t make it work yet in Python 2 (which has more mature libraries), I doubt it will work in Python 3.
I complained about this problem in my blog in 2011 (see post here). The situation is better in other languages, but not yet in Python.
- I have been building Media Computation examples in GP, a blocks-based language (see post here).
- Jeff Gray’s group at U. Alabama has built Blockly-like languages Pixly and Tunely for pixel and sample level manipulations.
- Cynthia Lee at Stanford has been doing Media Computation in her classes in MATLAB and in C++
- The Calico project supports Media Computation in IronPython (based on Python 3) and many other languages, because it builds on .NET/MONO which has good multimedia support.
When we did the 4th edition of our Python Media Computation textbook, I looked into what we’d have to change in the book to move to Python 3. There really wasn’t much. We would have to introduce
Interesting perspective from a blogger in the Scratch community, liked below. I do frequently hear the pattern described in the post quoted below. “I’ve started by daughter/niece/local-school on Scratch, and now I want to know how to move them into something ‘real’ (e.g., text).” I typically point them to amazing things that can be done in Scratch (like Alex Ruthmann’s beautiful livecoding of music in Scratch).
I recently got a chance to play with GP, a new programming language from John Maloney (of Scratch fame), where all blocks and texts are isomorphic. There’s a slider that lets you switch from one to the other. Even the debugger and class browser show up with tiles. Where does that play out in this debate? GP is the first blocks-based language I’ve used with the right primitives to do MediaComp, so I built one of my examples in it. Took me about three times as much time to write and four times as much space (in screen real estate) as in Python (even with John looking over my shoulder guiding me). Maybe that’s not a bad thing — maybe that encourages a different style of use. Next time I try something like that, I’m far more likely to think about building my own blocks and using more abstraction to save on dragging-and-fitting effort.
I’ve been a part of the Scratch community for about 8 years now (yes, really). During this time, I’ve noticed a pattern that seems to apply to a lot of people:
join Scratch => create projects => discover text-based programming => quit Scratch because of “real programming”
Note the scare quotes around “real programming”. Generally, a “real” programming language is text-based (C, Python, etc.) and apparently qualifies as real because it’s used by well-known developers for something.
Obviously I disagree with disqualifying Scratch as a real programming language.
JES 5.02 is now released at https://github.com/gatech-csl/jes/releases/tag/5.020. I have links to all the main downloads at http://mediacomputation.org .
Fixes in JES 5.02 (with many thanks to HenryStevens and sportsracer48 for fixes):
- Fixes a problem if you quit during raw_input that you can’t do another raw_input
- Makes the Sound explorer fully functional again
- Fixes colorizing
- Makes autosave work again
- Fixes a threading error if you hit return too rapidly in the Command Area
- Unicode characters in input file get flagged. (Jython can’t execute a line with unicode characters on it.)
You can find all the fourth edition Powerpoint slides (including a 68Mb zip of all of them) at http://coweb.cc.gatech.edu/mediaComp-teach/60. I’ve put some of the Peer Instruction question slides into the chapter PPT slide decks, but you can find more at the instructors-only website (see the Media Computation website for more on the teacher website).
Most of the changes are in the early chapters. Chapter 3 on text and language manipulation is all new. The latter chapter PPT slide decks have a few new slides in each deck, including:
- Creating state-preserving versions of picture manipulation functions in Chapter 16 on Functional Programming
- Subclassing Picture and Sound to move functions into methods in Chapter 17 on Object-oriented Programming
- Recursive turtle patterns, which are possible with an improved Turtle class in JES 5 in Chapter 17
Fourth edition of Python Media Computation released today: Teacher resources and desirable difficulties
According to Amazon, the Fourth Edition of the Python Media Computation book is released today (see page here). That’s the new cover above. I’ve been working on the 4th edition for most of the summer. Some of the bigger changes are:
- Before we manipulate pictures, we manipulate letters, words, and language, e.g., build “MadLib” and “koan” generators, and encoding and decoding keyword ciphers. Language is a medium, too, and it’s easier to get started (for some folks) with the smaller-iteration loops of text before getting to the thousands-of-iterations loops of pixels in a picture. It’s an optional chapter — everything introduced there gets introduced again later.
- Since the new version of JES fixed a round-off error in the Turtle class, we can do recursive turtle manipulations now (which tended to get messed up in earlier forms of JES).
- I juggled content around so that we do more with conditionals and querying the pixel for its position, before we introduce nested loops. Nested loops are really hard for students, and I learned (from seeing the code that my students wrote) that they can do far more than I’d guessed with single loops — even with multiple pictures. I included more of that.
- I have tried (for the last two editions) to provide screen-scraping examples, e.g., writing code to pull weather, news, or friends’ information from websites. It’s getting harder and harder to write that kind of code. Instead, I decided to provide more code that parses CSV files, as can be found at Open Data Journalism sites (like at The Guardian) and sources like the US Census. The examples are still about parsing out useful information, but it’s a lot easier to parse CSV and encouraged at these sites.
- There are more end of chapter problems, and new pictures. And trying to catch all the errors in the Third Edition that master teachers like Susan Schwartz (at West Point) found.
We’re working on teacher resources now. Currently in development (aiming to have ready in the next couple months) the Powerpoint slides for each chapter of the book, a collection of all the code in the book for teachers, and a solutions manual for every end of chapter problem. These are surprisingly controversial. There are lots (mostly University) teachers who think that I shouldn’t provide any of these resources — teachers should be able to develop all of those themselves. Most of the high school and community college teachers I know appreciate having them.
In searching for the Fourth Edition on Amazon, I read the comments on the Third Edition (see here). Authors probably shouldn’t read the reviews of the book — they’re painful. But I did, and even worse, I actually responded.
Here is a quote from one, titled “False Advertising.”
Its biggest problem: false advertising. This is NOT a book on Python, it’s about JYTHON – A Java based imitation of Python.
Why? Well, there’s some pretty software, available to download, which uses the the JRE. The author chose to stick with this “easy learning environment” and basically cripple anyone wanting to write Python code for Blender, Maya, Android etc.
You may learn to program from this text, but don’t expect a trouble-free life when you get exposed to the real language.
Here was my response:
Everything in this book is useful when wanting to write Python code for Blender, Maya, Android, etc. This is an introductory book on data, loops, conditionals, and objects. Those parts of Python are identical in this book and in the Python that you’ll use in Blender, Maya, and Android. For introductory Python programming, Jython and CPython are exactly the same.
I was surprised to see the original commenter responded. His point was that some kinds of friction, in dealing with the “real world” is desirable:
As an introductory book, I would expect a section on how to install and configure Python. Written covering Windows, Linux, and the Mac OSX. There is no such section; the whole point of Jython is to “hide” this technical level. Which is fine for learning loops etc. but leaves a student lost when encountering Python out in the real world.
It’s an interesting perspective, kind of a “rugged individualism” approach. I do agree with the notion of desirable difficulties in learning (see more here), but don’t agree that installing Python is one of those. Do most Python programmers install Python themselves, or is it already installed on the servers, computers, etc. that they will be programming? Is it a critical part of learning a language? Is it significantly different than installing JES (try that here)? Are you “lost” and unable to program if you don’t install it yourself first?
A sad addendum to this story: Our Media Computation data structures book (see the Amazon page here) has gone out of print. The publisher didn’t notify us. Someone approached us about using the book, and was told that it was out of print. When I queried Pearson, they admitted it. More, because it’s not out of print everywhere (I guess it’s available in some non-US markets), Pearson won’t let us post the content anywhere. It’s a dead book now.
African-American students preference for graphical or text-based programming languages depended on career goals
One of the results from Betsy DiSalvo’s dissertation on Glitch (see a post on that work) that I found most interesting was that there wasn’t a clear winner between graphical, drag-and-drop programming (Alice) and text-based programming (Python). She has now written up that part of the dissertation work, and it’s linked below.
To determine appropriate computer science curricula, educators sought to better understand the different affordances of teaching with a visual programming language (Alice) or a text-based language (Jython). Although students often preferred one language, that language wasn’t necessarily the one from which they learned the most.
- First, we’re on github! Come join us in stomping out bugs and making JES even better!
- Upgrading the Jython interpreter to version 2.5, making available new language features and speeding up many user programs. I have been working on the 4th edition of the Python MediaComp book this summer, and have introduced the time library so that users can actually time their algorithms (one of those CS Principles ideas), so I had ready-made programs to run in both JES4.3 and JES5.0. The speed doubled.
- Adding code to JES and the installers to support double-clicking .py files to open them in JES, on all supported platforms.
- Bundling JMusic and the Jython Music libraries, allowing JES to be used with the text “Making Music with Computers” by Bill Manaris and Andrew Brown. This is super exciting to me. All of their examples (like these) work as-is in JES 5 — plus you can do sampled sound manipulations using the MediaComp libraries. The combination makes for a powerful and fun platform for exploring computation and sound. My thanks to Bill who worked with us in making everything work in JES.
- Adding a plugin system that allows developers to easily bundle libraries for use with JES.
- Fixing the Watcher, so that user programs can be executed at arbitrary speeds. This has been broken for a long time, and it’s great to have it back. When you’re looking for a bug in a program that loops over tens of thousands of pixels or sound samples, the last thing you want is a breakpoint.
- Adding new color schemes for the Command Window, which allow users to visually see the difference between return values and print output. This was a suggestion from my colleague Bill Leahy. Students when first learning return can’t see how it does something different from printing. Now, we can use color to make the result of each more distinctive. Thanks to Richard Ladner at ACCESS Computing who helped us identify color palettes to use for colorblind students, so we can offer this distinction in multiple color sets.
- Fixing numerous bugs, especially threading issues. When we first wrote JES, threading just wasn’t a big deal. Today it is, and Matthew stomped on lots of threading problems in JES 5. We got lots of suggestions and bug reports from Susan Schwartz, Brian Dorn, and others which we’re grateful for.
Thanks to Matthew for pulling this all together! Matthew’s effort was supported by NSF REU funding.
Philip Guo did an analysis of what top CS departments teach in their introductory courses (see link below) and found that Python now tops Java. MATLAB tops C and C++ (though not if these are combined), and Scheme and Scratch are near the bottom.
It’s reasonable to say that an AP will only succeed (e.g., students will take it) if they can get credit or placement for the exam in college or university. Typically, colleges and universities give credit for courses that are currently taught. Will we see colleges and universities start teaching CS Principles? Will they give credit for a course that they don’t teach? For languages they don’t teach? Maybe we’ll see more of an influx of CSP languages and courses into colleges and universities. I predict that we won’t.
Scratch is the only visual, blocks-based language that made this list. It’s one of the most popular languages of this genre, which include related projects such as Alice, App Inventor, Etoys, Kodu, StarLogo, and TouchDevelop. The creators of these sorts of languages focus mostly on K-12 education, which might explain why they haven’t gotten as much adoption at the university level.