in which it is time for something that is almost completely different

«

»

Remember that funky leaf shape you used to draw with your ruler in math class in high school when you got bored? I can't be the only one who did this...

Right before _why the lucky stiff took himself off the grid I started reading up on his experiments with code and art, and he spoke pretty highly of the Processing language as a very approachable way to get into programming. As someone who got started coding in QBasic, I've always felt that the amount of effort needed to get started in most modern languages is quite a shame. Sure you can get going easily with text, but when you're new to it you want to see pictures drawn and colors fly around the screen. Processing restores that level of immediacy; if you want a line, you call the line function; there's no fussing with setting up an event loop or a menu bar or any of that nonsense.

chu

The problem is that while Processing is a great toolkit for drawing, it's is actually a pretty poor language when it comes to computational expressivity. It's statically-typed without any sort of inference, and there are no first-class functions or associative data type literals. Iteration is only possible using the most primitive of C-style for loops, and there's a shameful level of statefulness in much of the core functionality... You're not going to miss these things if you're just starting out with programming, but as a seasoned hacker, going back to a language like that feels quite limiting.

Luckily Processing is implemented on the JVM, so any other JVM-hosted languages can call out to it trivially. My weapon of choice right now is Clojure, and there's an adapter library that fits the bill nicely. (A ruby bridge exists too.) I've been playing around with it and have started a sketchbook project containing each of the programs I've written so far.

myu

The first thing you notice when you read up on Processing and take a look at some of the shorter sketches is that very simple ideas often yield interesting and subtle results. This image simply bounces a circle around the window while varying its opacity in a sine pattern. It's around thirty lines of Clojure, but you can see emergent weave patterns in it. This is a fairly common occurrence among Processing projects.

The canonical handbook by Reas and Fry has proven to an excellent introduction. It's geared towards beginner programmers, but the sections are broken up well so that it's easy to skip those on control and iteration while still getting a lot out of the more art-focused parts if you're coming from a programming background.

A nice bonus of being JVM-hosted is that it's possible to run Processing programs as applets (remember applets?) in the browser. I haven't gotten mine exported yet, but having the option to share easily makes it a lot more fun; I hope to have a sketchbook page uploaded soon. In the mean time it's on Github if you want to try it yourself.

Update: I've compiled all my sketches so far together for download. Depending on your OS you may be able to double-click on it; otherwise just launch it with java -jar sketchbook.jar. The chu sketch has trouble launching, and there's one bug where the sketches' window size is wrong upon launch, but you can adjust that.

« older | 2009-09-01T04:24:34Z | newer »