Experiments with ruby-processing (processing-2.2.1) and JRubyArt for processing-3.0

Showing posts with label development. Show all posts
Showing posts with label development. Show all posts

Saturday, 4 January 2014

Watch mode working again with P3D sketches in JRubyArt

Since this commit to vanilla processing the watch mode is now working in P3D. This was the result of a pull request from Jonathan Feinberg (processing.py), who realised which resources were not being released from such sketches (it was probably even more important for processing.py). It was Jonathans pull request that alerted me to the fact that it would be worth retesting with the latest development version of processing (which pulls his requested fix). Anyway the upshot is this will be automatically fixed for Linux and Windows users when the next version of processing gets released (Mac users if sticking with version 2.0.3 will not be so lucky). There exists a big opportunity for any Mac user brave enough to test the development versions of both processing and JRubyArt (next version of ruby-processing) to test if it can also work for them.
Anyway following my preliminary testing of "watch mode" with JRubyARt I can make the following suggestions to make your sketches more watch friendly:-
  1. Don't have no_loop in your sketch (it might not get updated) 
  2. If using constants use ||= to define them (that way you avoid complaint of already defined constant)
Anyway if you did not remember to do it before, you can (of course) do it in your first "edit" of the sketch.

Wednesday, 7 August 2013

Avoiding classpath conflict with jruby-complete

Well the simplest thing to do, would be ditch to jruby-complete, except:-
  1. Shader sketches still refuse to run. 
  2. We would lose export. 
  3. We would lose ability to install to system without requiring an installed jruby.
For me 1. is the biggest problem, any exported sketches will probably still be unable to use gems, also installing without jruby also means no access to gems.

See this gist for work in progress https://gist.github.com/monkstone/6172815. I propose to work on this independently on my monkstone branch will need updating from master. 


Motivation we could potentially use rubygems with P2D and P3D modes (even PImage sketches could not be run with rubygems). If we radically exclude jruby-complete until export gem would be much smaller.

Well it seem possible solution is to put jruby-complete.jar in its own directory, and possibly use:-

RUBY_PLATFORM == 'java'

So the solution is:-

Move ruby-complete.jar to its own folder (so we no-longer 'require jruby-complete.jar' in app.rb)

Dir["#{RP5_ROOT}/lib/core/\*.jar"].each { |jar| require jar }

Consequently we need to adjust the path jruby-complete.jar. And in the first place make sure we extract it to its new location easy. Seems to work, we retain the --jruby flag, which should be default unless we haven't installed jruby or we want to run shader sketches.

However it occurs to me this is the ideal opportunity to set using an external jruby as the default. Now all we need is a flag "--nojruby"  for when we need/prefer to use the included jruby-complete (which will remain handy to support export of applications). The shader sketches are the only ones now requiring such a flag. However it will also be required if ruby-processing gets installed without using system jruby (in this case you won't be able to use gems with ruby-processing). 

Well I've done it now since version 2.1.2 the default is to run ruby-processing from an external jruby, to revert to using installed jruby-complete now use the --nojruby flag (replaces the --jruby flag which had the opposite effect).

Followers

About Me

My photo
I have developed JRubyArt and propane new versions of ruby-processing for JRuby-9.1.5.0 and processing-3.2.2