P5.js vs javascript

I started p5.js recently. I never learnt javascript (the main javascript) at all. I have been learning only p5.js for almost 5 months…

But I always had a question in my mind that - “I have not learnt javascript. Can p5.js provide everything the main javascript could??”

Would you please answer it for me??
If the answer is ‘no’ , then should I learn the main javascript first for the other advantages? Or it’s just enough to be a nice developer by only learning p5.js?

1 Like

P5.js is a library, which works on top of javascript. It provides and extends the functionality of js for drawing things. And javascript itself is a programming language. When you are using p5.js you are using javascript.
You can do all the things that js provides in the sketch. But probably you have not used most part of js while making sketch.
I encourage you to learn js. While p5.js is a good start for beginners you need to learn other technologies(remember you do not need to know all.) to be a nice developer.

3 Likes

Hey There!

P5.js is an extra layer on top of JS like Processing Core on top of Java, it makes things alot easier. You can learn JavaScript if it’s something that yo7 require or are interested to do. But if P5 meets all your criteria it up to you. P5 is another layer of abstraction which can simplify things but does not necessarily have to be better because there can be things maybe which you would like to make differently then how P5 operates. Learning JS really depends what you are looking for / curiosity !

From Wikipedia:

As a multi-paradigm language, JavaScript supports event-driven, functional, and imperative (including object-oriented and prototype-based) programming styles. It has APIs for working with text, arrays, dates, regular expressions, and the DOM, …

JS is relatively easy to start w/, but very hard to master, due to its multi-paradigm nature, conflicting programming styles and never-ending competing frameworks (such as React, Angular, etc.)! :scream:

For plain-vanilla JS, best reference site is from Mozilla.org: :sunglasses:

  • W/ just p5js, you’re mostly programming in JS using the OOP paradigm style.
  • However, you still need to learn HTML & CSS in order to design web pages.
  • And to reach industry-level dev, you also need to learn some mainstream framework, such as React, Angular, etc.

There are also some languages which transpile to JS, such as TypeScript, CoffeeScript, etc.:

This is a good comparison to make, but also a bit misleading.

p5.js is written in valid JavaScript. When you write p5.js, you are writing JavaScript, but using a library.

Processing (Java mode) as documented in sketches and written in PDE with .pde files is not written in valid Java. Processing is its own Java-like dialect, and the contents of pde files must be transformed later into valid Java before it runs on a Java virtual machine. You can use Processing as a Java library (e.g. in Eclipse) and write it using valid Java – for what that looks like, see:

https://processing.org/tutorials/eclipse/

However none of the Processing examples or reference documentation demonstrate this valid Java mode – they are all in written in the Processing dialect for PDE.

2 Likes