interoperability between processing, processing.js, and p5.js?

Hi all,

I'm an experienced developer who's going through Daniel's 'The Nature of Code'. What I've got is a Java desktop application that I'm using to create Artificial Life environments. Eventually I'd like to port some of those environments to a web application. I was coding everything in straight Java but am considering a pivot to using Processing instead if it affords me the ability to easily plop the processing code I write for the Java desktop app into the web app. My questions are:

1) to what degree can I plop processing code into either processing.js or p5.js? 2) is it preferable to use processing.js or p5.js for this purpose? 3) I noticed processing.js isn't included in the processing website's nav bar but p5.js is. Is processing.js not affiliated/supported by the processing foundation?

t/y in advance for your insights!

Tagged:

Answers

  • Answer ✓
    1. If you don't rely on external libraries Processing code should transpile directly to JS using ProcessingJS (see below). p5js is written directly in JS so you need to rewrite your code to use it.
    2. If your intent is to re-use Processing's Java-based code directly online (without any re-writing) then ProcessingJS is the only option; albeit with some limitations (library support being the main one).
    3. Official support for online sketches now appears to be solely via p5js - hence no ProcessingJS link on the official site; but see this thread

    I have to say I'm a little disappointed by p5js. When I heard they had 'ported' Processing to JS I was happy: I've been coding JS professionally for a few years now and really enjoyed working with Processing in the past. But my feeling is that aiming for a direct port to JS was a mistake.

    The result (so far) is IMO some very odd design decisions (from a JS developers perspective) and the general impression that it doesn't play to the strengths of the JS language. I've persevered with it to see if I would change my mind; but so far remain unconvinced. I certainly wouldn't use it professionally: there are already more mature/powerful JS graphics libraries out there...

  • w00t! t/y for getting back to me so quickly. I was indeed looking to reuse the same code and more more than a little bummed that they seem to be dropping support for that feature (or at the very least, going in a different direction).

  • edited April 2016

    ... they seem to be dropping support for that feature...

    • They've already had since last year unfortunately. X(
    • However, Pjs is still relatively faster than the still immature & buggy p5.js! ;;)
    • But of course, p5.js is getting there by the day. :>
    • As mentioned, as long as we stick to Processing's API, cross-mode compatibility from Java to JS mode is pretty achievable.
    • I've had lotsa successful simple Java mode sketches which were fully convertible to JS mode automatically.
    • Here's a good example of the same sketch in Java-JS mode & p5.js:

    1. https://forum.Processing.org/two/discussion/8997/hoppy-beaver
    2. http://Studio.ProcessingTogether.com/sp/pad/export/ro.9bTfM49wCIJza
    3. http://p5js.SketchPad.cc/sp/pad/view/ro.GrwKUsycNrY/latest

    Another 1 w/ Pjs + p5.js versions to help you out. Even in Python Mode too: O:-)

    1. https://forum.Processing.org/two/discussion/14709/simple-p3-sketch-to-p5-js
    2. http://studio.ProcessingTogether.com/sp/pad/export/ro.9lMOG-RZX8JDk
    3. http://p5js.SketchPad.cc/sp/pad/view/ro.$V3VWYDTmRb/latest
  • edited April 2016

    pulling the trigger on this - thx for your help guys!

Sign In or Register to comment.