nannou-org / nannou

A Creative Coding Framework for Rust.
https://nannou.cc/
6.05k stars 306 forks source link

Port the Nature of Code examples over to run in Nannou #86

Open JoshuaBatty opened 6 years ago

JoshuaBatty commented 6 years ago

In order to both test the capabilities of nannou and it's API, and launch with some ridiculously handy tricks for users to reference, let's port of the Nature of Code examples written by Daniel Shiffman in Processing.

Below are a list of examples by chapter that i'll tick off and leave notes as I go.

Chapter 1: Vectors

Chapter 2: Forces

Chapter 3: Oscillation

Chapter 4: Systems

Chapter 5: Physics Libraries

Chapter 6: Agents

Chapter 7: Cellular Automata

Chapter 8: Fractals

Chapter 9: Genetic Algorithms

Chapter 10: Neural Networks

freesig commented 6 years ago

I'd love to give Agents a go if no one else is already doing this. This it could be good with the AI course fresh in my mind

mitchmindtree commented 6 years ago

Sounds good, go for it! Hit us up if you're unsure about anything :+1:

freesig commented 6 years ago

Hey how close to the original style are we aiming for? For example Rust usually encourages functions that apply to an struct vs calling methods on an object. Should we change the style to be more rustic? And perhaps a broader question, do we have a style we want to present in our examples? For example I know Mitch likes to try and compose values over nesting matches. Which I really like. I'm also a fan of using map map_err etc. over more verbose match where appropriate. This means using lots of closures which isn't a thing in processing. However it's a pretty valuable concept that I wish I was introduced to earlier and is also pretty rustic.

Clippy just got added to rustup and will probably be stable soon. Could be a good idea to run this on our code. I've found it pretty helpful in finding not so good style.

Also side question do we have stroke?

mitchmindtree commented 6 years ago

I'm more than happy to see the examples go with a more "rustic" style and take advantage of the tools/language features that rust has to offer. The original examples are written to fit the Processing language, so I think it's fine to adapt and modify them slightly to fit the Nannou and Rust, as long as they feel familiar, give the same results and the correlations are easy to notice when looked at side-by-side.

I feel like there are two goals that would be nice to keep in mind and balance as we work on these:

  1. I imagine many users will come from Processing, OF, etc, and this may be their first time exposed to rust code, so seeing a close mapping from the original examples to how it can be done in a familiar way in Rust could be a valuable, less-scary first impression.
  2. Nannou has the potential to not only reach existing creative coders, but to also 1. introduce other rustaceans to creative coding and 2. introduce brand new coders in a fun / interactive way. For these cases, I think it is important to attempt to remain idiomatic and apply good-practice, "rustic" conventions.

I think running clippy is an awesome idea! Would be stoked to see a PR applying clippy conventions :+1: I haven't used it, but what I've heard it sounds like clippy can be a bit overbearing at times, so maybe we should take each suggestion with a grain of salt. That said, I've also heard loads of good reviews and folks saying that it has helped them a lot when learning rust conventions.

jhaand commented 2 years ago

This is just what I've been looking for. Daniel looks like the guy to teach creative coding and Nature of Code still seems a great book to work through. Also I would like to get better with Rust and Nannou. Great to see that more people have the same idea and can get some help with this endeavour to get started.