Having fun coding with p5.js

p5.js is an effort to port the ideas and concepts of the Processing programming language to JavaScript.

Even though there’s already processing.js —which transcodes Processing code into JavaScript—, p5.js is built with extensibility in mind, trough plugins, and instead of writing Processing code to be transcoded, you write pure JavaScript.

The other day I saw the p5.js launch presentation, and loved it. It made me do several double-takes as it shows wizardly things that you usually don’t see on video.

So I gave it a whirl. Following the very detailed examples on their site I was able to quickly put together a web toy that records audio through your microphone and then allows you to reproduce it, changing the volume and speed. Here it is:
(you have to accept the microphone prompt in your browser in order for this to work)

Here’s the code in github

It was quick, painless and fun. In fact, this was the most fun that I’ve had in a long while learning a new JavaScript library. The onboarding experience that these guys have in their website it’s absolutely great.

I’ve never learned Processing, but have seen some wicked visualizations done with it. Seems like the routines and the concepts in p5.js are very similar, and the first thing that came to mind when I dove into it was Logo, my first language. I think it’s the procedural, sequential nature of it. The rules are very clear, each instruction modifies the context, and there’s this pervasive idea that you’re drawing in a canvas object in a web page.

I bet p5.js would make for a great introduction to programming for kids, with the added benefit that, along the way, any beginner that starts with p5.js would be learning one of the most popular languages today. And having fun at the same time.

p5.js website


I'm a software architect and I help people solve their problems with technology. In this site, I write about how to seize the opportunities that a hyperconnected world offers us. How to live simpler and more productive lives. I invite you to check the "Best of" section. If you want to contact me, or work with me, you can use the social links below.