« Back to Processing

Introduction to Processing

| No Comments | Published on March 25, 2008
The content that follows was originally published on the Don Havey website at http://donhavey.com/blog/tutorials/introduction-to-processing/

It’s time to get the real content started.

Processing is an open source programming language and environment for people who want to program images, animation, and interactions.

The Processing website states it pretty clearly. Processing is a tool used primarily for visualizing data. It is based on Java, but uses a much simpler syntax, and adds a very powerful set of graphic output tools. I would call it a fourth-generation language (others might say fifth- or sixth-generation): Java is based upon C/C++, which in turn is the offspring of the most ancient and revered ALGOL. My rule of thumb? The more generations the better. Unless you hate sunlight.

The tutorials that you’ll find on this site assume that you have some experience writing code… or at least that you aren’t daunted by the jargon. If you need a primer, the Processing website is the place to look. They have a number of tutorials and a helpful forum.

Let me start by describing Processing in relation to other languages.

Object-Oriented and Procedural

One of the unique characteristics of Processing is that it can be used in an object-oriented or procedural manner. Object-oriented code is generally more flexible and deployable, but procedural code can be much simpler to implement for small scale or calculation-heavy projects. I’m going to assume that you’re ready for object-oriented (abbreviated OO or OOP) solutions, as most of the tutorials I have lined up are fairly complex, and therefore require an object-oriented, class-based approach.

For the sake of comparison, Java is a strict object-oriented language. Actionscript is technically an object-oriented language, but you can think of Flash’s timeline as a way of using Actionscript procedurally. VBScript, Perl, and Fortran are examples of procedural languages.

Strictly Typed

Processing is a strictly typed language. Not “typed” as in keyboard. “Typed” as in “defined as a specific type of variable.” Variables are defined by their type. For example, a number would be defined using either the floating point type (for decimal numbers) or integer type (for integers). Once a variable’s type is set, it cannot be changed. However, values can be cast to a variable of a different type. For example:

int i = 6;  //i is defined as an integer, it must always remain an integer
float f = (float) i;  //the <u>value</u> of i is cast to a float
print("i = "+i+"   f = "+f);  //outputs "i = 6   f = 6.0" (notice the decimal!)

This strict typing system helps avoid compiling errors, but does limit Processing’s ability to deal with objects and arrays. If you’re used to programming with Javascript (not typed at all) or Actionscript (flexibly typed), this will be the hardest thing to get used to.

Inherent 3D Rendering

This is huge. There are two built-in 3D renderers available for use in the Processing environment: OpenGL and P3D. OpenGL tends to be the faster of two, and has more rendering options available. I use P3D only when I need to render lots of 2D text in 3D… which looks better than in OpenGL.

If you’ve ever written your own 3D rendering scripts in Actionscript (or similar), you’ll appreciate the ease with which Processing renders and transforms 3D objects and coordinates. It includes built-in matrix transformation tools for rotating and moving the camera. This aspect of Processing currently has no equal in any other programming language.

Okay. That’s it for the introduction. Next on the agenda is a look at some of the generic classes of mine that I’ll be using in the tutorials to come. Until then…

Categories: Processing / Tutorials

Tags: / / /

Leave a Response

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>