The Nature of Code

Author: Daniel Shiffman
Publisher: No Starch
Date: September 2024
Pages: 640
ISBN: 978-1718503700
Print: 1718503709
Kindle: B0CG8F2VKM
Audience: General
Rating: 5
Reviewer: Mike James
The nature of code - what is it?

If, on the basis of its title, you expect this book to give you the answer to what is the nature of code you are most likely going to be disappointed. The book isn't so much about the nature of code as the coding of nature. It's a wonderful book, but only if you are wanting to know what it is telling you.

In many ways it is a throwback to a time when there were lots of beginners wanting to know some very basic and very cool stuff about how to simulate things, how to do simple graphics, how to animate and so on. Today much of this has been taken care of by higher level applications, but if you still want to know about the basics then this book is what you are looking for.

It makes use of P5.js  which is a reimplemenation of Processing in JavaScript. Processing is a suite of Java functions that let you do creative things, mostly with graphics, very easily. P5.js isn't a port of processing, but it will let you do the same sort of things, but in the browser which often makes interactivity easier. This book is also a reimplementation of a very similar book that used Processing - both by the same author.

You would be well advised to know some JavaScript before staring on the book but the level of code isn't intimidating and you have plenty of opportunities to learn new things. One of the aims of the book is to teach you object oriented approaches to programming.

 

The book starts of with some very simple stuff - random walks - but it does serve to introduce some important ideas including probability, Gaussian distribution and so on. Next we move on to vectors and how to use them to implement dynamics. To make this more formal we next look at Newton's Laws of Motion - this book is as much about physics as it is about programming. To make this even clearer we next have chapters on simple harmonic motion and particle systems.

Having got simple dynamics out of the way the book starts to look at directed behavior and control in a chapter on autonomous agents and it goes from path following to flocking behavior. This is he sense that we are coding nature. To make things even more realistic the next chapter introduces the matter.js physics library and we get to do some of the stuff over again but this time using a library.

From here we move through a set of topics which are more loosely related. A chapter on cellular automata introduces some the early ideas the Wolfram explored - 1D automata and then on to the inevitable Game of Life and some fun extensions. Next come fractals but mostly focused on using the ideas as a way of generating interesting shapes. The genetic algorithm is next followed by neural networks. If you are looking for up-to-date coverage of either of these topics then you might be disappointed. The networks used here are very simple perceptron based shallow networks and it even covers the classical topics of regression and classification.  The final chapter puts networks and the genetic algorithm together to implement biological behavior.

This is a good read and it is a nicely produced book. Most people are going to know something about the topics covered as they are hardly new if you have been following this sort of work. Even so it is very nice to have the whole lot together in one place and if you are new to the ideas then you are in for a treat. Highly recommended if you want to play around with these ideas.

 

To keep up with our coverage of books for programmers, follow @bookwatchiprog on Twitter or subscribe to I Programmer's Books RSS feed for each day's new addition to Book Watch and for new reviews.

Banner


Algorithms: Absolute Beginner's Guide

Author: Kirupa Chinnathambi
Publisher: Addison-Wesley
Date: November 2023
Pages: 416
ISBN: 978-0138222291
Print: 0138222290
Kindle: B0CCTZ37DQ
Audience: General
Rating: 4.5
Reviewer: Kay Ewbank

Subtitled 'a practical introduction to data structures and algorithms in JavaScript', this book is split into tw [ ... ]



The C# Workshop (Packt)

Author: Jason Hales, Almantas Karpavicius and Mateus Viegas
Publisher: Packt
Date: September 2022
Pages: 780
ISBN: 978-1800566491
Print: 1800566492
Kindle: ‎ B0BGRBDJLS
Audience: C# developers
Rating:  4
Reviewer: Mike James
C# is not the language it once was - time for a revival?


More Reviews

Last Updated ( Wednesday, 12 March 2025 )