Shiffman teaches at NYU ITP/IMA, co-founded the Processing Foundation, and runs The Coding Train, which is how a huge chunk of people first learn creative coding without a CS degree. The Nature of Code (No Starch / Penguin, 2024) is the JavaScript and p5.js reboot of the 2012 Processing edition. Same mission: simulate natural systems in software so algorithms stop feeling like black boxes. The through-line that matters for anyone adjacent to AI work is that he builds all the way up to neural networks and neuroevolution in the browser, from vectors and forces, without asking you to treat a pretrained model as magic.
The book tells a three-part story. Part 1: inanimate objects that move under math you can name. Part 2: life-ish systems (agents, cellular automata, fractals). Part 3: intelligence (evolution, neural nets, neuroevolution). If you only want the ML chapters, you can jump there. You will understand them better if you earned the physics first.
Online edition and examples: natureofcode.com. Below, several chapters include a short runnable exercise (p5.js in the page): try the prompt yourself, then reveal a solution sketch.
Chapter by chapter
Introduction
Sets expectations: this is a survey that also wants to feel like a narrative, not a random grab bag of demos. Shiffman explains the move from Processing to p5.js, what you need to know coming in (basic programming comfort helps; you do not need a physics degree), and how the book pairs with Coding Train videos. He sketches the three-part arc and the recurring “Ecosystem Project”: keep extending one simulated world as chapters add mechanics.
The pedagogical claim is quiet and strong. Simulation is a way to learn both nature metaphors and code craft. For people drowning in LLM APIs, that claim is a useful counterweight: understanding comes from implementing the loop yourself.
Chapter 0: Randomness
Random walks, probability distributions, Gaussian noise, accept-reject sampling, and Perlin noise for smooth randomness. You build a Walker class and watch how different random processes look on screen. Uniform noise looks like static; Perlin looks like weather.
This is the right first chapter for simulation and for ML intuition. Stochastic processes are not “AI,” but if you cannot tell a uniform draw from a structured noise field, later talk about sampling and exploration is fog. Shiffman makes the difference visible.
Chapter 1: Vectors
p5.Vector as the vocabulary of motion: add, subtract, multiply, magnitude, normalize. Velocity and acceleration replace ad-hoc x = x + 1 hacks. Examples escalate from bouncing balls to mouse-seeking acceleration.
Vectors are the shared language between games, robotics, and a lot of classical ML feature geometry. The chapter is not linear algebra theater. It is “make the ball go where you mean.” That practical framing is why artists finish it.
Chapter 2: Forces
Newton’s laws as code: force accumulation, mass, friction, fluid resistance, gravitational attraction, n-body sketches. Multiple movers under shared force fields. The point is composition: many small force functions stacked into believable motion.
Anyone building agent sims, physics-informed toys, or even toy RL environments needs this muscle. Forces are how you encode “the world pushes back” without a full commercial engine.
Chapter 3: Oscillation
Angles, angular velocity, trigonometry, polar vs Cartesian coordinates, simple harmonic motion, waves, springs. Objects that rotate to face their velocity. Oscillators as reusable objects.
This is the chapter where sketches stop feeling like slides and start feeling like instruments. It also sneaks in the math that shows up later in periodic features, signal-ish visuals, and creature locomotion.
Chapter 4: Particle Systems
Hundreds or thousands of short-lived objects managed as one system. Emitters, inheritance and polymorphism for varied particle types, forces applied to whole systems. Smoke, fireworks, fountains: the classic demoscene vocabulary, taught cleanly.
Systems-of-objects thinking is the bridge to agents and to training loops that manage batches of entities. Pedantically useful OOP in a context where you can see when your design is wrong (the frame rate collapses).
Chapter 5: Autonomous Agents
Steering behaviors in the Reynolds tradition: seek, flee, arrive, wander, path following, group behaviors, flocking (separation, alignment, cohesion). Emergent “life” from local rules. The chapter is the emotional center of the book for a lot of readers: boids that suddenly look intentional.
If you work on multi-agent systems or want a visceral demo of emergence without a neural net, this is the chapter to assign. It also inoculates against magical thinking about “swarm intelligence” marketing. You can see every rule.
Chapter 6: Physics Libraries
When from-scratch force code is not enough: Matter.js and Toxiclibs.js for constraints, collisions, more elaborate bodies. The tradeoff is explicit. Libraries buy sophistication; you lose some pedagogical transparency.
Useful meta-lesson for AI tooling culture: know when to drop to a library and what understanding you are outsourcing when you do.
Chapter 7: Cellular Automata
Grid worlds, elementary CAs, Game of Life, more elaborate CA patterns. Local neighborhood rules, global structure. Wolfram-adjacent ideas without requiring you to buy a metaphysics.
CAs are a clean on-ramp to “simple update rules, complex outcomes,” which is half of what people mean when they gesture at complexity science or artificial life. Also a reminder that not all interesting computational behavior is gradient descent.
Chapter 8: Fractals
Recursion as geometry: Cantor sets, Koch curves, trees, L-systems. Branching structures that look organic because the rule is self-similar. The visual payoff is high; the conceptual load is mostly recursion comfort.
Generative artists live here. For ML-adjacent readers, it is a good place to feel the difference between hand-authored recursive structure and learned structure.
Chapter 9: Evolutionary Computing
Genetic algorithms: fitness, selection, crossover, mutation. Evolve designs or behaviors toward a goal. Smart rockets and related demos. Evolution as an optimization strategy you can watch generation by generation.
This is the overture to the ML ending. Evolutionary search is not deep learning, and Shiffman does not pretend otherwise. It is still one of the most teachable ways to show optimization under a fitness function, including how badly a bad fitness function steers you.
Chapter 10: Neural Networks
Perceptrons, multilayer networks, feedforward passes, training as adjusting weights from error. Classification and simple learning demos implemented so you can step through the math in code. No giant framework: the network is a thing you built.
This is the chapter people mean when they say Shiffman has an “ML book” inside the Nature of Code. It will not replace a proper deep learning course. It will make backpropagation stop feeling like a spell. For artists and engineers who only ever called an API, that demystification is the whole point.
Chapter 11: Neuroevolution
Combine chapters 9 and 10: evolve neural network weights (and sometimes topologies) with genetic algorithms instead of (or alongside) classical gradient training. Agents that learn to act in a simulated environment through selection pressure.
Neuroevolution is niche in industry ML and pedagogically gold. You see learning as a search process with population dynamics. It also connects cleanly to the book’s creature/ecosystem thread: brains and bodies co-evolve in a toy world you control.
Appendix: Creature Design Tutorial
A practical design appendix for building creatures that use the book’s mechanics. Less theory, more “assemble the parts into something that feels alive.” It is the studio handout at the end of the lecture.
Where I’d push back
This is not a machine learning textbook. Chapters 10 and 11 are excellent first-principles labs, not coverage of modern architectures, training infrastructure, evals, or the social stack around contemporary AI. Readers who need transformers, alignment, or production ML should treat NoC as intuition training, then move on. The p5.js choice is also a trade: maximum accessibility in the browser, less transfer to Python-native ML stacks without extra work.
Next to Christian’s The Alignment Problem, Shiffman is the opposite genre: you implement tiny learners instead of reading about lab-scale ones. Next to my own teaching notes on curriculum under model-speed decay, NoC is a reminder that some foundations (vectors, forces, simple nets) stay durable even when the frontier model card changes weekly.
For artists, educators, and engineers who want to see simulation and learning mechanics instead of only prompting them, this is still one of the best friendly technical books available. Read it with the site examples open; the book is built for that.
