Book Reviews

The Nature of Code: Simulating Natural Systems with Processing by Daniel Shiffman

ISBN: 0985930802
Publisher: The Nature of Code (None)
Pages: 520

The Nature of Code is a beautiful introduction to simulations of natural systems. Through Daniel Shiffman's concise prose, clear illustrations, carefully chosen systems and detailed code samples the reader is guided through the basic math behind our physical world into the corresponding computer representations in the Processing language. While Processing may not be the most elegant programming language in existence, it sure serves the purpose of this book.Visualizations are always low ceremony in Processing which allows the reader to focus on the concepts instead of the mechanics to express them. This is important because The Nature of Code goes well beyond Processing. The book is a solid introduction to basic game physics, randomness, genetic algorithms, cellular automatons, neural networks and much more.

The Nature of code is a self-published book backed as a Kickstarter project. While the book is available online in HTML, I do recommend you buy it. The layout and typesetting make it a joy to read. And since it's such a solid and interesting work I hope Daniel actually makes some money from it. It would be well deserved. It's rare that I pick up a programming book as inspiring as this one. Daniel Shiffman's style is that of a dedicated teacher communicating in an encouraging and enthusiastic voice. The Nature of Code was also a rare experience in that I actually worked through many of the exercises. I did it out of curiosity built-up by the code and simulations; what will happen if I actually change that noise level? Or how will it look in a third dimension? And what if the cells in Conway's classic game of life are allowed to wrap around the borders and spread life into their opposite neighbors? Someway, this is the hallmark of a great teacher. Communicating the same inspiration in written form is impressive.

The book covers a wide and diverse range of subjects. With such diversity it's quite natural that the book has to cover more breadth than depth. While the Newtonian physics and accompanying techniques to simulate motion are covered in adequate depth , probably deep enough to get started with some real-world simulations, more advances techniques are left superficially covered. I do wish the author went into more details on neural networks, the one chapter I found too thin, and perhaps had chosen a better example for his genetic algorithms (the current example are the classic monkeys trying to write Shakespeare on type writers, a fun problem that unfortunately doesn't convey the motivation for the solution approach). But these are minor nits. The book will give you a decent grasp about the basics and plant a seed of interest in the subject. You'll leave the book knowing enough about a particular subject to understand why it matters and get some ideas on future directions and resources.

Perlin noise - a visual effect based on gradient noise covered in the book (here the noise is used to simulate sunset lit clouds with Processing).

Finally some words on Processing itself, the programming language used in the book. Processing is a language and environment for creative coding. The language is compiled to Java and executes on the JVM. Processing uses much the same syntax as Java, just with some conveniences mostly prioritizing rapid feedback over solid design principles. I don't necessarily want to write more complex simulations in Processing. But as a platform for exploration and learning, Processing is an excellent choice. If you've experience with Java or some of its near relatives you'll pick up Processing in a breeze. I had a read through the online tutorials, mainly to get an idea of the graphics support, and skimmed through Daniel Shiffman's earlier book on Learning Processing. Initially I just planned to learn enough Processing to get the ideas in this book, but know I've found that I keep launching my Processing environment to explore other design ideas. Rapid feedback is truly addictive. Just like the concepts covered in this book stemming from nature itself.

Reviewed May 2013