Class Central is learner-supported. When you buy through links on our site, we may earn an affiliate commission.

# The Nature of Code

## Overview

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 class focuses on the programming strategies and techniques behind computer simulations of natural systems. We explore topics ranging from basic mathematics and physics concepts to more advanced simulations of complex systems. Subjects covered include physics simulation, trigonometry, fractals, cellular automata, self-organization, and genetic algorithms. Examples are demonstrated using the p5.js environment with a focus on object oriented programming.

Video featuring original artwork in P5.js by:
Particle Equalizer #1 by Sehyun Kim
Look at me! by Muqing Niu
Dancing Spring by Yue Hu
FireWork by Yue Hu
Nature Of Code final at ITP by Joe_Mango
Nature of Code - midterm by Marcela Nowak
Sound And Motion Coding by Marcela Nowak

## Syllabus

Session 1: Introduction / Overview
In this session we’ll review the basics of p5.js and get everyone up and running with posting sketches online. We’ll look at how object-oriented programming works in JS and create simple sketches of objects moving around a canvas. Session 2: Vectors / Forces
This session will look at the concept of a vector and implement sketches using a p5.Vector object. By creating objects with vectors for position, velocity, and acceleration, we’ll build a simple “hello world” physics engine. Session 3: Steering Behaviors
This session, we’ll examine a special kind of force (pioneered by Craig Reynolds) — a steering force — that moves an object according to its own goals or desires. Examples are wandering, seeking a target, path following, obstacle avoidance, and more. We’ll then look at how group behaviors can be simulated by combining multiple steering behaviors according to local interactions between objects. Session 4: Fractals
In this session we will cover the concept of a fractal and look at ways of generating fractal patterns with code. Session 5: Genetic Algorithms
This session will look at the key concepts of Darwinian evolution — variation, selection, heredity — and examine how they can be applied in a computer simulation.

Daniel Shiffman

## Reviews

5.0 rating, based on 18 reviews

Start your review of The Nature of Code

• Anonymous

Anonymous completed this course.

Dan is an unbelievable teacher! I always wanted to go to NYU but in reality I could never afford it. Thank you for sharing this knowledge with the world. I bought your book last year but this class really helped me step through it piece by piece. It is not an easy course. But I can't believe what I was able to create! The best part was seeing what other students were making at the same time from all around the world. Thank you. Thank you. Thank you.
• Anonymous

Anonymous completed this course.

This was a great course. Dan is a very dynamic, entertaining and funny teacher. The video lectures were well done and the assignments appropriate to the content. The last session seemed a little compressed – a couple of advanced subjects that might have been better as separate session/assignments – but overall it was an excellent course. I have done several courses on Kadenze and this was one of the best.
• Anonymous

Anonymous is taking this course right now.

Dan Shiffman has great courses on his youtube channel. Coding Rainbows! But this course is so well made. Only on week 1 but cant wait for the next sessions to be released! Also great to see other students work in the gallery.
• Rates

Rates completed this course and found the course difficulty to be hard.

Dan Shiffman is a brilliant educator - he explains complex ideas in a relaxed and fun style. The world needs more teachers like Dan!

This is not a beginner course and you will have to put in some time to explore on your own to get the most out of it, but definitely worth it.
• Anonymous

Anonymous is taking this course right now.

I stumbled upon Dan Shiffman's one-hour of code video a few months ago and I'm now officially hooked and trying to watch every tutorial videos/course he makes. I didn't know anything about code before and the way he explains it make it very accessible and also pushes me to know more and more. I highly recommend his course.
• Anonymous

Anonymous completed this course.

Easily the best online course I've taken so far!
I really appreciate the focus on just getting things working from the start, as opposed to (most other courses) lecturing on and on about 'theory' without application.
As others have said, Daniel Shiffman's youtube channel "Coding Rainbow" is definitely worth checking out as well. It's a looser/informal version of this course, covering loads of cool topics.
• Anonymous

Anonymous completed this course.

Daniel Schiffman is a great teacher : bright, enthusiastic, interesting and entertaining.
That mooc is a really good way to level up your practice in p5js and your understanding of physics simulations.
• Anonymous

Anonymous completed this course.

This is the most interesting course for creative programming, or simply if you are a programming enthusiast. The course materials are excellent, and provide a wide range of personal exploration, and you are able to model many interesting, real or fictional, natural scenarios.
• Lachlan Cromie

Lachlan Cromie is taking this course right now, spending 4 hours a week on it and found the course difficulty to be medium.

This course has been amazing and I have grown massively as a programmer because of this and so thank you to Daniel Shiffman for this course. I can't wait for the final lesson coming out tonight.
• Anonymous

Anonymous is taking this course right now.

Love this course! Also love the YouTube tutorials, can't wait for more! So far, what seemed really too complicated for me is made easy.
• Paolo Pastorino completed this course, spending 5 hours a week on it and found the course difficulty to be hard.

Dan is a great teacher, his enthusiasm is addictive.
The course was organized very well and i found it very interesting.
• Anonymous

Anonymous completed this course.

Dan is one of the most engaging teachers I have ever seen, the content is superb, I just wish it was longer! Love this course and his YouTube channel!
• Anonymous

Anonymous is taking this course right now.

I could not go till the end of the course. But it was great and I am looking forwards for the next section. Dan is really a very good teacher, his teaching is great. And fun at the same time. Thanks.
• Anonymous

Anonymous completed this course.

I have been following Daniel sir since couple of years and as coding is not my primary field still these tutorials helped me a lot. There is no way I could express my gratitude and best wishes.
• Anonymous

Anonymous completed this course.

Great course. I loved it. Great course. I loved it. Great course. I loved it. Great course. I loved it. Great course. I loved it. Great course. I loved it.
• Anonymous

Anonymous completed this course.

Great course with a terrific teacher (I started following Dan Shiffman on Youtube after completing the course). I learned a lot and there are many connected topics and areas that got me interested — simulations, games, P5.js in general, etc.
• Anonymous

Anonymous completed this course.

Excellent Introduction for new concepts. Instructor with a charisma of transferring Knowledge..
Do at your own pace scheme offers flexibility for completing assignments and deepening of understanding of concepts. Multitude of potential application of acquired knowledge on completion of course.
• Anonymous

Anonymous completed this course.

Great course if you already know the basics of programming, it will also strengthen your OOP skill.
It also showed me the importance of math formulas.

## Class Central

Get personalized course recommendations, track subjects and courses with reminders, and more.