Can I follow The Nature of Code with Python instead of p5.js?
Asked by
MellowCactus42
I'm fairly new to programming, with most of my experience coming from GCSEs, and I want to work through The Nature of Code because the topics look really interesting. The examples appear to use p5.js, but I currently know Python and would rather improve my Python skills than learn JavaScript right away. I initially referred to the tool as "j5," but I meant p5.js. I've also run into installation problems: the p5-related command works, but running code says I need a Java 17 virtual machine. I'm not sure how to install that, and I've also wondered whether I need an older Python version and how to keep multiple Python versions installed independently.
Answers
p5.js is a JavaScript library, not Java, so the bookโs examples arenโt written in Python. You can translate the ideas into Python, but graphics and interaction code will need equivalents using something like Pygame, Tkinter, or a Python creative-coding library. That may be more difficult than following the examples directly. Also, The Nature of Code has material for both p5.js and Processing, so check which version of the examples youโre using. If the tool you installed specifically requires Java 17, install a Java 17 JDK from a reputable distribution such as Eclipse Temurin, then restart your terminal and check it with `java --version`. You shouldnโt need to downgrade Python just to use p5.js; if you do need another Python version, a virtual environment or a version manager can keep it separate from your current installation.
Reply to this answer
Add your answer
Answers are reviewed before publication.
Related Discussions