home art portfolio sketches

My experience with Processing

I have seen and dabbled with Processing a couple times over the past few years, but it wasn’t until I was in a computational art program that I spent real time with it. Over the past few months I tried to write a new “sketch”, a program in Processing terms, every day to play with a different aspect of graphical programming like shaders, color modes, 2D motion, arduino integration, kinect interactivity, image pixel manipulation, and more.

I have to say overall I love what Processing has done and so I’ve collected my thoughts and experiences of using it over the past few months. I’ll go over technical issues, user experience, and my hopes for Processing. To help understand my point of view, I will give a little history of myself. I’ve essentially programmed a little bit of everything, dozens of web apps, machine learning pipelines, sales and marketing tools,devops and system admin, backend systems,deep learning models, and now graphical programming. I also study programming languages: clojure, common lisp, ruby, python, bash,javascript, php, C, erlang, haskell, java, prolog, smalltalk; the weirder the language, the more interest in it I have.


In terms of the name Processing, it is a terrible name for searching online. Processing is such a generic term and is used for every type of computation and so it is extremely rare when I search for Processing with any other phrase, that I get what I want in the first try. Many other languages like ruby or python have this same problem,but I would say nowhere as severe as Processing. With p5js, things get a lot easier search wise. Tip, if you can’t find info in google, switch out Processing for p5js.

freezing editor

The editor completely freezes on me several times a week. If I type something wrong,access variables that don’t exist, cause the memory to shoot up, or other mistakes, often times Processing will completely die or freeze and I have to force quit it. On top of that, sometimes I have forgotten to save my code and I end up loosing some of my work. This sucks, I wish the editor was not tied to the sketch running. This ends up with me wasting a lot of time. I usually end up coding with 2 terminal windows, one for vi and the other for running my sketch and it runs flawlessly and faster.

So I wrote lots of sketches to display at a showcase. I wanted to have each sketch run for a few minutes, then go on to display the next one, essentially running in “gallery mode”. So I googled for it, coudln’t find anything, it doesn’t exist. So then I went to ask a few Processing experts, they all said, “yes, this is common, its very easy to do, all you do is modify all your code to fit into one master sketch and just write a little code to switch between sketches” Are you kidding me? I have to change all my code around to present my sketches? I ended up writing a simple command couple line script so you can place all your Processing sketches into a directory and the script will rotate between them every X seconds. Gotta love the power of unix! Since each sketch is reloaded with a fresh java process, there can be a noticeable delay of 2-3 seconds between sketches depending on the speed of your computer. You might want to use a background image on your desktop to convey to the user to wait a monement.

poetic computation

I think most coders try to write things as succinct and efficiently as possible. With Processing, I saw myself taking this to another level and that is because when writing Processing code, you are essentially writing applied mathematics. As a web programmer or backend programmer, you just don’t spend as much time using math. And so as I wrote my Processing code, I found myself trying to rewrite it to be more elegant and more mathematically pleasing. I find myself trying to remove as many if statements as possible. Often times this leads to more efficient code. Processing has rekindled my love for mathematics.

computer science and math education

In school I studied mathematics and computer science and since then I have always been interested in figuring out how to get more people interested in learning to program. I’m a firm believer that programming can solve everything :) I think Processing could be a wonderful tool for teaching computer science. Processing definitely has problems as a teaching language, but I think its better than most of the stuff out there. Imagine teaching students to use fundamental computer science and math algorithms by writing them in Processing and then for homework having students tweak various aspects of the algorithm and show the results visually.

I don’t know if it exists, but I would love to see someone come up with a full computer science curriculum using Processing as the main language.

on java

Processing is written on top of java. I would say that is both a good thing and a bad thing. I personally loath java, its so painful for me to write in that last time I had to program in java, I immediately learned clojure so I could avoid java. For Processing, I understand why they went with java, Java was a good choice because they could build on top of an existing system, its cross platform, and there are tons of libraries to integrate with. The bad side is that the code is verbose,ugly, and slow to startup. People don’t enjoy writing in java. I was tempted to just start writing Processing code in jruby or clojure, but didn’t want to add another level of abstraction and so far have stuck with java. I wonder what Processing would look like if it was written from the ground up as a new programming language. Would it be as successful as it is today? I think there is still room for visual programming language written from scratch.

Processing vs p5.js

So p5.js is Processing written on the javascript runtime. That means you can easily write and deploy your Processing sketches to the browser. When I started this adventure a few months ago, I was trying to decide whether I should use Processing or p5.js. In hindsight, I’m pretty sure I made the right decision, p5.js is not as powerful, you can’t integrate it with as many libraries, it is much harder to debug your code, it is not as mature as Processing, and it seems to run slower. Even with the small sketch I wrote here of the abstract buddha, I originally wrote it in Processing, works fine, then I ported it to p5js. In safari it runs fine, but in chrome it slows down the whole page and looks like it freezes for a minute at a time. Power of computation was the main factor in my choice, so if you need raw power, Processing is the better choice. So how does one choose the right version to use? Are they both going to remain actively developed? Can they do the same things? Is p5.js the successor? It is a little confusing, other people have asked this same question in the Processing forums. And from the Processing foundation’s point of view, I hope they can focus on one of these great platforms, not divert limited resources to both.

gateway drug

So over the past few months, I did some tests where I walked through writing a Processing sketch to 3 types of people: programmers, techies who don’t code, and non techies. I wanted to see if I could get them excited to do more programming. I saw the most excitement from programmers and some excitement from techies. Not exactly the level of enthusiasm I was looking for, but I think my pitch and content need more fine tuning. Part of the feedback I got was, “this is cool, but what can I use this for?” To me, I think what the question really means is “how can computational artists make a living” which is a topic I’ll write about later. I think with the right content, Processing could get a lot more people interested in visual coding and coding in general. The content needs to progress from very simple to progressively challenging, all while remaining visually pleasing. As I mentioned in the beginning of this post, I had already dabbled with Processing before, but at those times I just wasn’t really interested. So what was it that got me excited about it this time? I think it was becauseI had an upcoming computational art show and I had been doing image processing with deep neural networks. I think things like raspberry pi and Processing combined could help get people interested in this space.

raspberry pi

So Processing is supported on the raspberry pi. It is still very early stage though, it runs extremely slow on the raspberry pi and you have to follow some special instructions to get it working properly, making it a bad experience. For an art installation I was working on, I tried to use raspberry pi, Processing, and a webcam. The code was too slow and webcams don’t seem to be supported, so I ended up using a mac mini. In my tests, 95% of all the programs I ran are too slow. It is not uncommon to have code that ran at 60 frames per second on your mac to run at 3 frames per second, unusable! I think Processing and Pi could be a powerful force to get people interesting in visual programming, but the way it is now is a missed opportunity. I found lots of optimizations and tricks to make your code run faster and I plan to write up those notes in a separate blog post. I keep a raspberry pi with Processing loaded in my backpack now to show people! I would absolutely love to see a future where raspberry pi can be used to teach and deploy Processing artworks. Keep in mind you have to write in Processing, p5.js doesn’t really work on the raspberry pi :(

daily sketching and closing remarks

I have tried to write a new Processing sketch once a day, but usually ends up at ~3 sketches a week. I find writing a sketch to be like an artist practicing painting. It is fun, therapeutic, and helps you improve your coding practice. I want to help get more people involved in visual coding, so My friend,Agustín Ramos Anzorena and myself are working on a site called pushpopchallenge to practice writing a sketch everyday. Several times a week, there are different challenges where you can practice visual coding. One day it might be try to do a ocean simulation and the next day it might be to draw meteoroids. I hope it can help you and give you inspiration to paint with code.

If any of this sounds interesting to you, please contact me to collaborate.