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

Showing posts with label jruby-9000. Show all posts
Showing posts with label jruby-9000. Show all posts

Saturday, 10 May 2014

Enhanced exception handling in ruby 2.1.0

This one was promoted by headius (Charles Nutter), so guaranteed to work with jruby-9000? Get access to the cause of the original exception, when re-thrown.
class ExceptionalClass
  def exceptional_method
    cause = nil
    begin
      raise "Boom!" # RuntimeError raised
    rescue => e
      raise StandardError, "Ka-pow!"
    end
  end
end

def setup
  size 500, 120
  background 50, 50, 200
  f = createFont("Arial", 16, true)
  text_font(f, 16)
  fill(255, 0, 0)
  begin
    ExceptionalClass.new.exceptional_method
  rescue Exception => e
    exception = "Caught Exception: #{e.message} [#{e.class}]"
    cause = "Caused by : #{e.cause.message} [#{e.cause.class}]"
    text(exception, 20, 30)
    fill(255, 255, 0)
    text(cause, 20, 60)
  end
end


Exploring ruby-2.1.2 syntax in ruby-processing

To run the following sketch you need to be using jruby-9000 (the development version of jruby which supports ruby 2.1.0 syntax out of the box), here I am actually used JRubyArt the development version of ruby-processing (that uses jruby-9000 by default). This sketch uses the very concise syntax for rationals in ruby-2.1.0 (fractions for the masses)
def setup
  size 640, 250
  background 10
  f = createFont("Arial", 24, true)
  third = 1 / 3r     # since ruby 2.1.0
  quarter = 1 / 4r
  add = "#{third} + #{quarter} = #{third + quarter}"
  subtract = "#{third} - #{quarter} = #{third - quarter}"
  multiply = "#{third} * #{quarter} = #{third * quarter}"
  text_font(f, 24)
  fill(220)
  text("Math blackboard ruby-processing", 80, 50)
  text(add, 110, 100)
  text(subtract, 110, 150)
  text(multiply, 110, 200)
end


 
Update 16th November, after a long hiatus the sketch is now working again with jruby 9000.dev-SNAPSHOT (2.1.2p142) 2014-11-08 8a13045 OpenJDK 64-Bit Server VM 24.65-b04 on 1.7.0_65-b32 +jit [linux-amd64]. Unfortunately not many others sketches will currently run...

Tuesday, 10 December 2013

Time to give up on the Mac

I have started a new development fork of ruby-processing, I am calling it JRubyArt, there will be no support for the Mac (in the foreseeable future, possibly never, depends on active co-operation Mac users). Calling it JRubyArt may not be so daft because the end point need not only be a processing sketch (PovRAY or Sunflow).
It is an absolute requirement of the development branch to be using at least java-7 (this is requirement for processing-2.1+, but I am really targeting java-8). The idea is that JRubyArt keeps step with jruby-9000 development (which will likely require at least java-7, but likely to work best with java-8). On this basis, there is absolutely no point in supporting the Mac, which post Maverick seems to be designed not to work with java (having said that many jruby users have Macs go figure).

Thursday, 3 October 2013

Checking out jruby-complete-9000.dev.jar (waiting for jruby-1.7.5)

I just tested the 2 October 2013 snapshot of jruby-complete-9000 with ruby-processing, so far so good (still issue with fisica library that I had thought had gone away with jruby-1.7.5.dev, but I might have been using my "corrected" version of the fisica library, anyway I will be interested to see the effect of Charlies pruning basically removing ruby-1.8.7 compatibility). I've also been reviewing "app.rb", with a view to being a bit more specific about which processing classes to import. Having failed abysmally to make any use of processing event classes directly, they are in firing line. Also I will only import opengl classes for P2D and P3D sketches (work in progress, will be ready for next ruby-processing commit to coincide with jruby-1.7.5 release). On the processing front a new release of vanilla processing may not be too far away either (at long last, and then probably only because of the Mac Retina display issue, java version is going to be upgraded to version 1.7.0_40).

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