Page 154 - Hacking Roomba
P. 154
Chapter 7 — Making RoombaView 135
to learn. Flash, Max, and most Java IDEs cost several hundred dollars and are entirely propri-
etary. One of the goals of this book is to enable you to write Roomba code for free.
Ease of Use
The fact that Processing calls its programs sketches is telling. Even if you are an expert pro-
grammer, sometimes you just want to whip up something quickly. Processing is a great
environment for getting coding ideas up and running fast, especially if they have an animated
graphics component.
Full Access to Java
Although Processing presents a simple command set for doing common things, it doesn’t pre-
vent you from including and invoking other Java classes. In fact, it’s pretty easy to use the full
Java class library or wrap up any other Java class into a Processing library. This is what is done
to allow RoombaComm to be used.
Cross-Platform Compatibility
When Sun introduced Java, one of the company’s slogans was “write once, run anywhere.” Java
promised a world of easily shared code, compiled on a single machine and sent through the
network to run on any machine. This is mostly true, assuming the Java VM is the same version
on every platform. In practice, there are several different versions of Java VMs out there, all
with different capabilities and bugs. Much effort is being expended in the Java developer com-
munity to solve this problem, but it still persists. Processing outdoes Java in a few ways. First, it
obviates the Java VM versioning issue by ensuring that whenever you use Processing, you get a
consistent Java VM environment. Second, it enables the sketch author to make dynamic web
pages out of his or her sketch with a single button press, making sharing of running code a
piece of cake. Third and most importantly, it goes the extra distance that Java never did and
produces true applications for Windows, Mac OS X, and Linux. To the user of Processing, the
difference between making a web page applet and a full application is the difference of deciding
which Export button to press.
When Not to Use Processing
In general, Processing is meant as a code-sketching environment. You wouldn’t want to build a
large application with it. Processing is simply a tool that helps you try out ideas fast.
Processing supports an animation metaphor but it is not a full replacement for an animation
package like Flash. Processing’s vector art support is relatively weak and drawing complex
shapes with it can be exhausting. It can work with video, but not with the same alacrity as
Max/MSP/Jitter. It can produce applets like Flash, but Java applets seem to always load slower
and tax the system harder than the equivalent Flash applet.
Although almost every aspect of Java can be used within Processing, using the Swing or
AWT GUI components of Java can be challenging, because Processing assumes a certain level
of control over the graphics environment.
If you find that doing something in Processing is becoming too difficult, don’t hesitate to drop
it and adopt a different methodology.