Can I follow The Nature of Code with Python instead of p5.js?

0
7
Asked By MellowCactus42 On

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.

1 Answer

Answered By SilverMaple7 On

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.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.