P.1 What is this book?

At ITP, I teach a course entitled Introduction to Computational Media. In this course, the students learn the basics of programming (variables, conditionals, loops, objects, arrays) as well as a survey of applications related to making interactive projects (images, pixels, computer vision, networking, data, 3D). The course mostly follows the material found in my intro book Learning Processing; in many ways, serves as a follow-up. Once you’ve learned the basics and seen an array of applications, your next step might be to delve deeply into a particular area. For example, you could focus on computer vision (and read a book like Greg Borenstein’s Making Things See). In the most basic sense, this book is one possible next step in a world of many. It picks up exactly where Learning Processing leaves off, demonstrating more advanced programming techniques with Processing that focus on algorithms and simulation.

The goal of this book is simple. We want to take a look at something that naturally occurs in our physical world, then determine how we can write code to simulate that occurrence.

So then what is this book exactly? Is it a science book? The answer is a resounding no. True, we might examine topics that come from physics or biology, but it won’t be our job to investigate these topics with a particularly high level of academic rigor. Instead, we’re going to glance at scientific concepts and grab the parts that we need in the service of building a particular software example.

Is this an art or design book? I would also say no; after all, we are going to focus on algorithms and their affiliated programming techniques. Sure, the results will all be visual in nature (manifested as animated Processing sketches), but they will exist more as demonstrations of the algorithms and programming techniques themselves, drawn only with simple shapes and grayscale. It is my hope, however, that designers and artists can incorporate all of the material here into their practice to make new, engaging work.

In the end, if this book is anything, it is really just a good old-fashioned programming book. While a scientific topic may seed a chapter (Newtonian physics, cellular growth, evolution) or the results might inspire an artistic project, the content itself will always boil down to the code implementation, with a particular focus on object-oriented programming.

P.2 A word about Processing

I am using Processing in this book for a number of reasons. For one, it’s the language and environment with which I am most comfortable, and it’s what I enjoy using for my personal work. Two, it’s free, open-source, and well suited to beginners. There is an active, energetic community of people who program with Processing; for many, it’s the first programming language they’ve learned. In this sense, I hope that I can reach a wide audience and demonstrate the concepts in a friendly manner by using Processing.

All that said, there is nothing that ties what we are doing in this book strictly to Processing. This book could have been written using ActionScript, JavaScript, Java (without Processing), or any number of other open-source “creative coding” environments like openFrameworks, Cinder, or the newly released pocode. It is my hope that after I’ve completed this book, I’ll be able to release versions of the examples that run in other environments. If anyone is interested in helping to port the examples, please feel free to contact me (daniel@shiffman.net).

All of the examples in this book have been tested with Processing 2.0b6, but for the most part, they should also work with earlier versions of Processing. I’ll be keeping them up-to-date with whatever the latest version is. The most recent code can always be found on GitHub.

P.3 What do you need to know?

The prerequisite for understanding the material in this book could be stated as: “one semester of programming instruction with Processing (including familiarity with object-oriented programming).” That said, there’s no reason why you couldn’t read this book having learned programming using a different language or development environment. The key here is that you have experience with programming.

If you’ve never written any code before, you are going to struggle, because this book assumes knowledge of all the basics. I would suggest picking up an introductory book on Processing, a number of which are listed on the Processing website.

If you are an experienced programmer, but haven’t worked with Processing, you can probably pick it up by downloading Processing, poking through the examples, and reading through the Getting Started page.

I should also point out that experience with object-oriented programming is crucial. We’ll review some of the basics in the book’s introduction, but I would suggest reading the Processing tutorial on objects first.

P.4 What are you using to read this book?

Are you reading this book on a Kindle? Printed paper? On your laptop in PDF form? On a tablet showing an animated HTML5 version? Are you strapped to a chair, absorbing the content directly into your brain via a series of electrodes, tubes, and cartridges?

The book you are reading right now was generated with the Magic Book project. The Magic Book is an open-source framework for self-publishing developed at ITP. The idea here is that you only need to write the book once as a simple text file. Once you’ve written your content, you press a magic button, and out comes your book in a variety of formats—PDF, HTML5, printed hardcopy, Kindle, etc. Everything is designed and styled using CSS. As of the first release, the only versions available will be digital PDF, printed hardcopy, and HTML5 (which will include animated versions of the examples using Processing.js). Hopefully over the course of the next year, the book will be available in additional formats. If you’d like to help with this, please contact me (daniel@shiffman.net).

P.5 The “story” of this book

If you glance over the book’s table of contents, you’ll notice there are ten chapters, each one covering a different topic. And in one sense, this book is just that—a survey of ten concepts and associated code examples. Nevertheless, in putting together the material, I had always imagined something of a linear narrative. Before you begin reading the chapters, I’d like to walk you through this story.