Can we capture the unpredictable evolutionary and emergent properties of nature in software? Can understanding the mathematical principles behind our physical world help us to create digital worlds? This book focuses on the programming strategies and techniques behind computer simulations of natural systems using Processing.
Processing enthusiasts rejoice! There is a new book coming by Daniel Shiffman and it’s called Nature of Code. As it’s title implies this book takes phenomena that naturally occur in our physical world and shows you how to simulate them with code. Nature of Code picks up where Daniel’s last book Learning Processing leaves off, demonstrating more advanced programming techniques with Processing that focus on algorithms and simulation. In that sense, it’s not an introductory textbook. This becomes clear in the very first chapters. Instead of going over basics such as variables, for loops and arrays this book starts with topics like vectors and randomness. The whole book feels a bit like a narrative rather than just a loose collection of code snippets. Especially the first chapters really build upon each other, gradually introducing important concepts and programming techniques.
Chapter one starts with a clear explanation of vectors, which not only lays a solid foundation for the rest of the book but also for all programming endeavors beyond that. Chapter two is all about simulating forces. From gravity to friction and even attractors. Chapter three is “the math chapter”, covering trigonometry among other things. Not pretty, but pretty useful.
Things really start to get interesting from chapter four onwards, which covers the creation of several fully fleshed-out particle systems. During the course of this chapter inheritance and polymorphism are also discussed. These are extremely important programming concepts that will not be familiar to many beginning Processing users. Chapter five continues by examining two open-source physics libraries, Box2D and Toxiclibs’ verlet physics engine.
Chapter six covers autonomous agents, little virtual entities making decisions in response to their environment. While the individual elements of such a system may be simple, the behavior of the system as a whole can be highly complex. Chapter seven is about cellular automata, a system of cells living on a grid. Fractal patterns inspired by the geometry of nature can be found in chapter eight.
Chapters nine and ten are about intelligence. Very fitting, because they require the most attention to grasp. Evolution of code, genetic algorithms and neural networks are not light subject matter. But they are highly suitable to end an advanced programming book. Since this is the kind of material that you won’t understand easily just by looking at example code and because it’s always a good idea to end on a high note.
Every book needs a finishing touch. Learning Processing had Zoog making appearances throughout the book. Nature of Code has the Ecosystem Project, a series of challenges at the end of each chapter. Once succesfully completed, they convoy the reader into building a complete ecosystem.
Also noteworthy is the way Nature of Code came about and the way it is published. Starting as a Kickstarter project, reigning in over six times the requested amount, Daniel was launched into writing this book in april 2011. While it took quite some time to get to the finish line, the race (read: marathon) helped improve the book itself. Because drafts where released during this period, people were able to get a glimpse of the work-in-progress, give valuable feedback and catch remaining errors. But even more admirable is the publishing philosophy. The entire book is made available online for free under a (noncommercial/attribution) Creative Commons license. Similarly, all code examples from the book are available online as well via the book’s main site or github.
All in all Nature of Code is a very interesting, fun and well-rounded book that is both suitable for use during programming courses and for structured self-study. I would recommend it to everyone with an interest in coding, except perhaps absolute beginners. It’s especially useful for coders who want to simulate natural phenomena or those who want to sharpen and upgrade their programming skills. It’s content makes Nature of Code the kind of book you’ll want to own. It’s publishing philosophy makes it the kind of book you’ll want to support. Get the PDF now at NatureOfCode.com and expect the print release in the coming weeks!
Posted on: 02/11/2012