tabreturn.github.io

Overview of Tools Combining Processing and Python

2022-08-02

A while ago, I was reading over (and responding to) a post on the Processing forums. The thread discussed the future of Processing Python Mode / Processing.py, but that’s not exactly what this blog post is about. What inspired me was one particular comment from Setsuna that read:

“py5, p5py, and now pyp5js… Is the community trying to get the newbies confused? Because it’s working.”

– Setsuna, from the Processing forums

Setsuna makes a valid point. People involved in developing Python implementations of Processing should take note. Processing.py, py5, p5py, and pyp5js are all excellent tools that combine Python and Processing; then, there’s Shoebot, DrawBot, and similar projects that incorporate Processing ideas into a Python solution, albeit in ways that deviate more from the typical functions and workings of Processing. Each tool offers unique abilities and advantages (and trade-offs), creating a richer Python creative coding ecosystem. However, with so many options, it’s easy to overwhelm a would-be creative coder, educator, or anybody else interested in exploring Python as a language for learning programming and creative computing applications.

A Video Explanation to Try Clarify Everything

Enough introduction already! I presented on the topic of Python-Processing tools at SIGGRAPH 2022. You can view the presentation at https://dl.acm.org/doi/10.1145/3532836.3536231
(the recording is under the Supplemental Material heading)

The talk maps out the Python-Processing landscape, offering insight into the different options/libraries/tools and providing direction for beginners, teachers, and more accomplished programmers keen to explore Python as a tool for creative coding projects.

Watch the video at https://dl.acm.org/doi/10.1145/3532836.3536231

The presentation begins with a light introduction to Processing, focusing on how Python Mode (also referred to as Processing.py) leverages Jython to interface with Processing’s Java core. The explanation for how this works is the basis for describing the workings of several other Python-Processing tools.

I mention this in the video, but I’ll state it here – I consider Alexandre Villares’ Processing + Python tools table the most well-maintained and concise summary of tools that combine Python and Processing. The webpage also lists other related tools (Shoebot, Blender’s bpy, and more).

Alexandre Villares' resources for teaching programming

I must also note that, subsequent to my producing the video for SIGGRAPH, the Processing Foundation has invited Tushar Gupta to work on integrating Skia as a 2D back-end renderer for p5py. This will provide a significant performance boost and enhance several aspects of the project.

Why Python?

I believe that a large part of the success of Processing (and by extension, p5.js) is its appeal to creatives and first-time coders. But, in my opinion, Python is a better language (than Java or JavaScript) for those users – Python can do more in a single line than most other languages, and there’s less having to tell beginners, “don’t worry about that part, I’ll explain it later.” Even Ben Fry, Processing co-creator, thinks that “Python is terrific.”

Brian Kernighan, the co-author (with Dennis Ritchie) of the influential book The C Programming Language, provides some interesting opinions about first-time programming languages in a recent Computerphile interview. Of course, I’m (more than a little 😉) inclined to agree that Python is an excellent entry into programming, but it’s also an in-demand language for professional work. This ‘low floor, high ceiling’ aspect of Python is immensely beneficial to learning environments, for students who enter courses with prior programming knowledge and experience and those who desire to explore beyond the course content in their project work. What I’m looking for in a teaching setting is the most effective language to teach ‘creative’ students transferable concepts and programming skills to serve as a basis for further teaching down the line (follow-on courses in multimedia, web-app, and game development). In reality, they’ll have to learn several languages through a degree programme, but Python seems the best fit to start that journey and is sure to be something they encounter again later on.

Kernighan’s point on ‘instant gratification’ is poignant – something that Processing does so well by generating graphic output with little more effort than opening the pared-down coding environment and typing a line or two of code. Moreover, visually-oriented programming tasks fit excellently into a degree catering to students of creative technologies.

A Word on py5

I must disclose that I’m involved in the py5 project, so I’m more than likely biased.

In addition, I’m working on a py5 plug-in for the Thonny IDE that transforms Thonny into a Processing-PDE-like alternative for creative coding with Python. Consider that beginners can’t differentiate a library from a language from an IDE. “Processing” is just “Processing”, IDE and all (as opposed to an IDE combined with the Processing library, requiring users to express themselves in Java). My plug-in, thonny-py5mode – which includes a selection of handy menu items and a Processing-like color scheme – aims to emulate the Python Mode experience from Processing’s PDE with as little installation fuss as possible.

The thonny-py5mode plug-in

Unlike Processing’s Python Mode / Processing.py, py5 supports Python 3 and works with other popular Python libraries and tools such as Jupyter, NumPy, and Pillow. Picking up an earlier point about low floors and high ceilings, here’s another insightful quote from py5 creator, Jim Schmitz

“Scratch is good for beginners, but you can’t really go very far with it, so people might not want to invest a lot of time and effort into learning it. Python and py5 can go very far, so beginners can see a path from their first steps to something more ambitious, such as a program that combines py5 with Python ML tools.”

Did I mention py5 also supports Jupyter Notebook environments?

py5 running in Jupyter Notebooks

To close with another Ben Fry quote on Python (with reference to Processing.py’s Jython implementation): “it’d be awesome to have available NumPy and all those other things that make Python wonderful.” Hello py5!

End

References

  • https://discourse.processing.org/t/what-is-the-future-of-processing-python-mode/35009/20
  • https://github.com/villares/Resources-for-teaching-programming
  • https://py5.ixora.io/