B'more on Rails Message Board › JRuby Presentation Followup

JRuby Presentation Followup

Keith B.
keithrbennett
Reston, VA
Post #: 46
All -

Thanks for the opportunity to speak at the meeting last week, and for keeping it lively with questions.

There are some links below, at the end of this message. Also, I've looked into resolving some of those questions, and here's what I found:

1) Where is JRuby's sprintf functionality implemented?

Just as Chris said, JRuby's sprintf functionality is written in Java. It is distinct from Java's sprintf functionality and C Ruby's sprintf implementation. It is, of course, intended to be identical in *behavior* with C Ruby's sprintf.

The JRuby sprintf Java code is at https://github.com/jr...­.


2) I mentioned that I was unable to see any effect of the JRuby use of 'include' to indicate that the class in which it is declared implements a certain interface.

I made a sample script to illustrate it, posted it on Github (https://gist.github.c...­, asked on the JRuby mailing list about it, and got an answer from Charlie Nutter, principal architect and author of JRuby. He said that the include statement is not necessary, but using it will allow JRuby to do things to improve performance and Java integration:

"Using include will perform a bit better because we can immediately see the interfaces the object supports and we also can make the Java object representing the Ruby object *actually* implement those interfaces rather than generating/instantiating a separate object attached to the Ruby object.

"I believe dispatch from Java through the interface is faster using a class + include than the "magic" form too."

3) I was not clear in my description of the function 'become_java!'

It is used in conjunction with the adding of (Java) annotations to a JRuby class. In order for the added annotations to be accessible to Java, it is necessary for the class to be Java class. (In contrast, it is *not* necessary for a class to be a Java class to implement a Java interface; a Ruby class works fine.)

Links

Presentation Slides - https://speakerdeck.com/u/keithrbennett/p/jruby-the-synergy-of-ruby-and-the-jvm­

"Using JRuby" - an excellent book about JRuby, at http://pragprog.com/book/jruby/using-jruby­

- Keith

--
Keith Bennett
http://about.me/keithrbennett­
Powered by mvnForum

Our Sponsors

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy