Talking more about JRuby

For the most part, we've been pretty good about keeping JRuby discussions off the ruby-talk list, because in general it seemed like the right thing to do. But lately, it seems like people are missing information about what JRuby can do, how complete the implementation is, and where we're going with it. So I'd like to start talking more about JRuby on this mailing list.

I'll start it off with a little introduction to JRuby and what it can do right now.

JRuby is Ruby for the JVM, also known as the Java Virtual Machine. It's written mostly in Java, though there's some libraries written in Ruby, and we include the entire Ruby 1.8.x (currently 1.8.5) stdlib.

In the 1.0 line, JRuby operates primarily as an interpreter comparable to the standard Ruby 1.8.x implementation.

In 1.1, JRuby includes a 100% complete Ruby-to-bytecode compiler, that increases performance substantially.

JRuby runs Rake, RubyGems, Rails, Mongrel, and nearly all pure-Ruby libraries and apps that are out there. Compatibility has gotten closer and closer to 100% over the past year.

There are a number of organizations rolling out real production Rails apps on JRuby rather than on regular Ruby, usually because JRuby fits better into Java-oriented organizations, but increasingly because JRuby offers libraries, stability, and performance characteristics in many ways better than running on the standard implementation. It's not better across the board, but it's starting to be better in very important areas.

JRuby 1.0.1 is the current release. 1.0.2 is going to be released within the next two weeks, along with a beta of 1.1.

What more would folks like to know about?

- Charlie

Charles Oliver Nutter wrote:

[snip]

JRuby 1.0.1 is the current release. 1.0.2 is going to be released within the next two weeks, along with a beta of 1.1.

What more would folks like to know about?

1. When do you figure the "release" of 1.1 will be?
2. What's the "API" for mixed Java and Ruby programming on the Java platform?
3. Do you *have* to write jRuby extensions in Java, or can you write them in bytecode? In C?

I'd just like to say, thank you so much for JRuby. I haven't had a chance to actually use it yet, but the fact that it's out there means a lot to me.

My dad is a Java fanatic. Drinks his coffee every morning, then goes and practices Java.
When he saw this on a job application (like "have you ever done JRuby"), he wanted to learn more about it. So now he's starting out.

But here's my question:

Can you set the compiler to generate the .class files, and then just run those on someone else's computer?

Thanks,
Ari
--------------------------------------------|
If you're not living on the edge,
then you're just wasting space.

···

On Oct 28, 2007, at 2:45 AM, Charles Oliver Nutter wrote:

What more would folks like to know about?

I have had a hard time keeping track of the different deployment options for
deployment of Rails applications on JRuby. I try following all of your
blogs but I'm not sure what is the recommended setup. I'm familiar with
mongrel from MRI, however, I'm not a Java guy. When it comes down to
Tomcat, GlassFish, etc. what are my best (from performance to simplicity)
options? What are the best options for packaging my applications for
deployment to these application servers? I have seen mention of goldspike
and warbler but I am not sure which I should be using.

Like I said earlier, I'm not a Java guy but my interest has grown since
seeing JRuby come to life. Here are some other questions from someone
lacking Java experience/knowledge.

1. Specific areas that Java can handle that MRI currently has no solution
for, libraries, interesting tricks, etc...
2. This has more to do with Java and less to do with JRuby, but what are
some good resources for learning Java?
3. What about JRuby internals? There is
http://eigenclass.org/hiki.rb?ruby+internals+guide for MRI. I'm sure
something like this would be useful for educating people interested in
contributing to JRuby.

I have been watching the progress of JRuby over the past few months and I am
extremely impressed. You guys are making amazing progress!

Thanks!
Michael Guterl

···

On 10/28/07, Charles Oliver Nutter <charles.nutter@sun.com> wrote:

There are a number of organizations rolling out real production Rails
apps on JRuby rather than on regular Ruby, usually because JRuby fits
better into Java-oriented organizations, but increasingly because JRuby
offers libraries, stability, and performance characteristics in many
ways better than running on the standard implementation. It's not better
across the board, but it's starting to be better in very important areas.

JRuby 1.0.1 is the current release. 1.0.2 is going to be released within
the next two weeks, along with a beta of 1.1.

What more would folks like to know about?

Charles Oliver Nutter wrote:

What more would folks like to know about?

I's like to know more about non-Rails Ruby Web apps that use JRuby.

Packaging, deployment, known issues, what's needed, etc.

I expect Charlie probably cannot answer all of these for the myriad Ruby Web frameworks out there, so if anyone has experience or observations about using JRuby with Nitro, Camping, Ramaze, Iowa, etc. please speak up.

Thanks!

···

--
James Britt

www.ruby-doc.org - Ruby Help & Documentation
www.rubystuff.com - The Ruby Store for Ruby Stuff
www.risingtidesoftware.com - Wicked Cool Coding

Oliver, first of all thank you for the hard work! I hope I get to use
JRuby soon - but as always it's a matter of resources (time in this
case).

···

2007/10/28, Charles Oliver Nutter <charles.nutter@sun.com>:

In the 1.0 line, JRuby operates primarily as an interpreter comparable
to the standard Ruby 1.8.x implementation.

In 1.1, JRuby includes a 100% complete Ruby-to-bytecode compiler, that
increases performance substantially.

What more would folks like to know about?

Why did you not label the "ruby to bytecode" version 2.0 instead -
this seems like a major architectural change and it would have been
worth a major release, wouldn't it?

Kind regards

robert

thing which impressed me most at your excellent mtn. west rubyconf talk was the little swing demo: the ability to quickly (or more quickly) write cross platform desktop applications is quite interesting. perhaps i'm not the only one to consider that a fully ajaxified, or even single page, desktop app offers little more, in some respects, than a java application that connects to a central db.

so i'm primarily interested is seeing how we can use jruby to open up new markets to ruby like desktop applications, running jruby in the browser, etc. maybe jruby can bring back the applet!

it is very exciting and i personally wouldn't mind seeing more of it on ruby-talk

kind regards

a @ http://codeforpeople.com/

···

On Oct 28, 2007, at 12:45 AM, Charles Oliver Nutter wrote:

What more would folks like to know about?

--
we can deny everything, except that we have the possibility of being better. simply reflect on that.
h.h. the 14th dalai lama

I thought Mongrel was a Ruby / C hybrid. How does this run on JRuby -
using JNI?

···

On Oct 28, 2:45 am, Charles Oliver Nutter <charles.nut...@sun.com> wrote:

JRuby runs Rake, RubyGems, Rails, Mongrel, and nearly all pure-Ruby
libraries and apps that are out there. Compatibility has gotten closer
and closer to 100% over the past year.

M. Edward (Ed) Borasky wrote:

Charles Oliver Nutter wrote:

[snip]

JRuby 1.0.1 is the current release. 1.0.2 is going to be released within the next two weeks, along with a beta of 1.1.

What more would folks like to know about?

1. When do you figure the "release" of 1.1 will be?

We're targeting Decemberish, probably around JavaPolis (EU java conference) timeframe. One big milestone for a Ruby conference, the next for a Java conference.

2. What's the "API" for mixed Java and Ruby programming on the Java platform?

Generally, it's pretty trivial.

require 'java' # or "include Java" via an autoload we support
SomeClass = com.foo.bar.SomeClass
sc = SomeClass.new

And we add lots of nice features for certain standard Java types and interfaces, like making collections Enumerable and so on.

http://www.headius.com/jrubywiki/index.php/Calling_Java_from_JRuby
http://blogs.sun.com/coolstuff/entry/using_java_classes_in_jruby

3. Do you *have* to write jRuby extensions in Java, or can you write them in bytecode? In C?

Extensions...well, generally, you have to write extensions in any language that compiles to Java bytecode. You could write them in Scala, Python (Jython), or Groovy if you really wanted to. It's all just bytecode.

We do not support C-based extensions or libraries. However, we are shipping the Java Native Access library (JNA) in JRuby 1.1, which provides programmatic access to any C library from Java code (it's similar to what DL provides for Ruby). That should make it a lot easier to wire in C-based libraries to JRuby.

It's fair to say that the limitations of the JVM and the Java platform apply to JRuby, like some difficulty calling native libraries and the ever-present startup time issue. But the benefits also apply, in the way of performance, excellent GC, concurrent multithreading, and a massive collection of libraries.

- Charlie

Ari Brown wrote:

What more would folks like to know about?

I'd just like to say, thank you so much for JRuby. I haven't had a chance to actually use it yet, but the fact that it's out there means a lot to me.

My dad is a Java fanatic. Drinks his coffee every morning, then goes and practices Java.
When he saw this on a job application (like "have you ever done JRuby"), he wanted to learn more about it. So now he's starting out.

But here's my question:

Can you set the compiler to generate the .class files, and then just run those on someone else's computer?

Yes, you can precompile .rb files and use them as standalone files. There's a minor startup hit for loading precompiled classes, but the upside is that you don't have to wait for JRuby to JIT compile them at runtime as they're used; they'll be fast immediately.

What we don't have just yet is all the nice little features a compiler should have, like compiling an entire target directory, compiling to a specific output dir, tasks for rake, raven, buildr, maven, ant, whatever. We also are looking for input on how best to incorporate the compiled files into the loading process. Like Python's pyc files, where if the compiled file is newer it runs that, otherwise it runs the uncompiled .py file?

It's also worth mentioning that the compiled Ruby files are not really directly-usable Java classes...they're compiled Ruby scripts. Just as you can't instantiate a script as its own object or call methods directly on a script, so can you not do that with a compiled Ruby script. You must launch or the script and let it run through, defining methods and classes and so on.

I have plans for a second compiler that will turn a Ruby class into a more normal, instantiable, callable Java class, but that will come after 1.1.

- Charlie

···

On Oct 28, 2007, at 2:45 AM, Charles Oliver Nutter wrote:

Michael Guterl wrote:

I have had a hard time keeping track of the different deployment options for
deployment of Rails applications on JRuby. I try following all of your
blogs but I'm not sure what is the recommended setup. I'm familiar with
mongrel from MRI, however, I'm not a Java guy. When it comes down to
Tomcat, GlassFish, etc. what are my best (from performance to simplicity)
options? What are the best options for packaging my applications for
deployment to these application servers? I have seen mention of goldspike
and warbler but I am not sure which I should be using.

To be honest, I'm as confused as you are. There's a massive simplification that needs to happen somewhere. Warbler has helped a lot though, and it's being used internally by Sun to package Rails apps as WAR files. I'd expect the Warbler approach is most people will want to follow in the future.

What we really need is this kind of feedback, to smack the GoldSpike and Warbler people around and let them know "this is getting too complicated". You should pass that along on the JRuby or JRuby-Extras mailing lists (and if you have any ideas, you should offer them...even if you don't think you're qualified. The "Java way" is very often the wrong way.)

Like I said earlier, I'm not a Java guy but my interest has grown since
seeing JRuby come to life. Here are some other questions from someone
lacking Java experience/knowledge.

1. Specific areas that Java can handle that MRI currently has no solution
for, libraries, interesting tricks, etc...

That would be a good list to have; it's just hard to assemble because of the massive number of such areas. GUI development has really captured a lot of attention in JRuby recently, since Swing is a great low-level API and Ruby is a gerat high-level language. The two together make GUI programming almost fun. Others might include Java's better support for XML manipulation, remote services, garbage collection/memory management, and arguably an easier language for writing extensions.

2. This has more to do with Java and less to do with JRuby, but what are
some good resources for learning Java?

For learning the language, probably the Deitel books, "Core Java", and a few others. It's been a long time since I had to learn Java, so I'm not a great reference here.

If you're planning to primarily use Ruby on the JVM, you can generally get by with just the documentation associated with various class libraries, starting with Java's own libraries here:

http://java.sun.com/j2se/1.5.0/docs/api/index.html

Like I say, it's an extensive collection, even in just the base distribution of Java. And all those libraries are usable in JRuby with normal Ruby code.

3. What about JRuby internals? There is
http://eigenclass.org/hiki.rb?ruby+internals+guide for MRI. I'm sure
something like this would be useful for educating people interested in
contributing to JRuby.

There's one article on the JRuby wiki...I've intended to write more but haven't had a chance yet:

http://www.headius.com/jrubywiki/index.php/JRuby_Internal_Design

I'd be interested in hearing what specific areas of this need to be expanded on. In general, JRuby's internal design isn't very complicated, especially if you exclude parsing and compilation. The interpreter's pretty straightforward and the core class impls are easy to follow.

I have been watching the progress of JRuby over the past few months and I am
extremely impressed. You guys are making amazing progress!

Thank you :slight_smile: It's been a long hard process, but we're finally starting to meet many of our longer-term goals.

- Charlie

James Britt wrote:

Charles Oliver Nutter wrote:

What more would folks like to know about?

I's like to know more about non-Rails Ruby Web apps that use JRuby.

Packaging, deployment, known issues, what's needed, etc.

I expect Charlie probably cannot answer all of these for the myriad Ruby Web frameworks out there, so if anyone has experience or observations about using JRuby with Nitro, Camping, Ramaze, Iowa, etc. please speak up.

I can talk about one option that *should* be in 1.1: Ruvlets.

Tom Enebo has been working on a nice, simple Ruby-based servlet API for folks wanting to use Ruby but not wanting to wire in Rails or another large framework (or for people wanting to easily wire framework X into a servlet environment). It goes something like this:

ruvlet.rb:

   def service(request, response)
     # handle request, send response
   end

And that's about it for the simplest case. You stick this in a WAR file with the Ruvlet servlet configured, and it will be routed all requests. There's increasingly more specific mechanisms for wiring things up too, from specific HTTP request types to basic request routing to different scripts. But it's nice and simple, with no cgi.rb overhead and with a choice of dozens of high performance WAR-based server front-ends.

I'd love to hear if people are using JRuby for the others. I know Camping works, but I don't know if there's any major JRuby Camping users yet.

- Charlie

Robert Klemme wrote:

Why did you not label the "ruby to bytecode" version 2.0 instead -
this seems like a major architectural change and it would have been
worth a major release, wouldn't it?

Well that's a good question. I think we'd always expected that 1.1 was going to be a "big" release, given that we had so many 0.0.x increments that were smaller-but-still-substantial architectural changes. I suppose one reason we didn't go straight to a 2.0 release is that we always wanted the compiler to be complete for 1.0, but there simply wasn't enough time to make it happen in the 1.0 plan. Our releases have been very heavily driven by conference dates; we simply couldn't pass up JavaOne for 1.0. And going with a 1.1 now at "mid year" gives us the opportunity to complete the "ultimate changes" we have planned in a 2.0 release this spring.

- Charlie

ara.t.howard wrote:

What more would folks like to know about?

thing which impressed me most at your excellent mtn. west rubyconf talk was the little swing demo: the ability to quickly (or more quickly) write cross platform desktop applications is quite interesting. perhaps i'm not the only one to consider that a fully ajaxified, or even single page, desktop app offers little more, in some respects, than a java application that connects to a central db.

so i'm primarily interested is seeing how we can use jruby to open up new markets to ruby like desktop applications, running jruby in the browser, etc. maybe jruby can bring back the applet!

Ara, if you're at RubyConf this weekend, ask me about Monkeybars.

We at Rising Tide are doing interesting work with JRuby & Swing.

it is very exciting and i personally wouldn't mind seeing more of it on ruby-talk

Agreed

···

On Oct 28, 2007, at 12:45 AM, Charles Oliver Nutter wrote:

--
James Britt

www.ruby-doc.org - Ruby Help & Documentation
www.risingtidesoftware.com - Wicked Cool Coding
www.rubystuff.com - The Ruby Store for Ruby Stuff
www.jamesbritt.com - Playing with Better Toys

ara.t.howard wrote:

What more would folks like to know about?

thing which impressed me most at your excellent mtn. west rubyconf talk was the little swing demo: the ability to quickly (or more quickly) write cross platform desktop applications is quite interesting. perhaps i'm not the only one to consider that a fully ajaxified, or even single page, desktop app offers little more, in some respects, than a java application that connects to a central db.

so i'm primarily interested is seeing how we can use jruby to open up new markets to ruby like desktop applications, running jruby in the browser, etc. maybe jruby can bring back the applet!

Yeah, that's probably worth another thread. Ruby+Swing seems to be one of the most popular uses for JRuby right now. There's something like 4 or 5 different Swing frameworks for Ruby as a result.

- Charlie

···

On Oct 28, 2007, at 12:45 AM, Charles Oliver Nutter wrote:

Brian Adkins wrote:

···

On Oct 28, 2:45 am, Charles Oliver Nutter <charles.nut...@sun.com> > wrote:

JRuby runs Rake, RubyGems, Rails, Mongrel, and nearly all pure-Ruby
libraries and apps that are out there. Compatibility has gotten closer
and closer to 100% over the past year.

I thought Mongrel was a Ruby / C hybrid. How does this run on JRuby -
using JNI?

Only a small portion of Mongrel is written in C; those bits have been ported, and an upcoming release of Mongrel will have a JRuby platform-specific gem available.

- Charlie

Quoth Charles Oliver Nutter:

...
Java 2 Platform SE 5.0
...

Does this mean JRuby targets 1.5.0? What about 1.6.0 or 1.4.x? These are just
things I'm interested in, as long as you're on ruby-talk.

Thanks,

···

--
Konrad Meyer <konrad@tylerc.org> http://konrad.sobertillnoon.com/

Charles Oliver Nutter wrote:

James Britt wrote:

Charles Oliver Nutter wrote:

What more would folks like to know about?

I's like to know more about non-Rails Ruby Web apps that use JRuby.

Packaging, deployment, known issues, what's needed, etc.

I expect Charlie probably cannot answer all of these for the myriad Ruby Web frameworks out there, so if anyone has experience or observations about using JRuby with Nitro, Camping, Ramaze, Iowa, etc. please speak up.

I can talk about one option that *should* be in 1.1: Ruvlets.

Tom Enebo has been working on a nice, simple Ruby-based servlet API for folks wanting to use Ruby but not wanting to wire in Rails or another large framework (or for people wanting to easily wire framework X into a servlet environment). It goes something like this:

ruvlet.rb:

  def service(request, response)
    # handle request, send response
  end

That looks pretty much like Rack.

   http://rack.rubyforge.org/doc/

And that's about it for the simplest case. You stick this in a WAR file with the Ruvlet servlet configured, and it will be routed all requests.

Might be interesting to JRubyify Rack, or make Rack and Ruvlet easily interchangeable, so that Rack-ready frameworks (Ramaze, Nitro, Camping, Sinatra, others) can pop over to JRuby.

···

--
James Britt

"The use of anthropomorphic terminology when dealing with
computing systems is a symptom of professional immaturity."
  - Edsger W. Dijkstra

We just did some work this week so that all of Merb's specs pass on JRuby and you can run merb apps under the jruby mongrel.

Cheers-
-Ezra

···

On Oct 28, 2007, at 10:43 AM, Charles Oliver Nutter wrote:

James Britt wrote:

Charles Oliver Nutter wrote:

What more would folks like to know about?

I's like to know more about non-Rails Ruby Web apps that use JRuby.
Packaging, deployment, known issues, what's needed, etc.
I expect Charlie probably cannot answer all of these for the myriad Ruby Web frameworks out there, so if anyone has experience or observations about using JRuby with Nitro, Camping, Ramaze, Iowa, etc. please speak up.

I can talk about one option that *should* be in 1.1: Ruvlets.

Tom Enebo has been working on a nice, simple Ruby-based servlet API for folks wanting to use Ruby but not wanting to wire in Rails or another large framework (or for people wanting to easily wire framework X into a servlet environment). It goes something like this:

ruvlet.rb:

def service(request, response)
   # handle request, send response
end

And that's about it for the simplest case. You stick this in a WAR file with the Ruvlet servlet configured, and it will be routed all requests. There's increasingly more specific mechanisms for wiring things up too, from specific HTTP request types to basic request routing to different scripts. But it's nice and simple, with no cgi.rb overhead and with a choice of dozens of high performance WAR-based server front-ends.

I'd love to hear if people are using JRuby for the others. I know Camping works, but I don't know if there's any major JRuby Camping users yet.

- Charlie

I agree that the options here are confusing and not well documented.
It's not clear that there's a single approach. This speaks mostly to
the relative immaturity of the options combined with the fact that
there have always been many, many ways of deploying applications in
the Java world.

Hopefully as these options have time to bake, they will crystallize
around a couple of approaches:

1. Deployment ease with a minimum of knowledge of the Java platform
and application servers. Comparable to the MRI/mongrel combo today.
The Glassfish gem [1] will hopefully address this need.
2. When there is existing Java infrastructure/application servers, or
you want to run multiple Rails apps on a single server, WAR file
deployment packaged with Warbler [2], and using whatever glue works
and performs best to patch Rails into the servlet environment.
Currently this is Goldspike [3] (which Warbler packages today), but
other approaches are being worked on as well.

/Nick

[1]: http://weblogs.java.net/blog/arungupta/archive/2007/09/announcing_glas.html
[2]: http://caldersphere.rubyforge.org/warbler/
[3]: Welcome to headius.com

···

On 10/28/07, Charles Oliver Nutter <charles.nutter@sun.com> wrote:

Michael Guterl wrote:
> I have had a hard time keeping track of the different deployment options for
> deployment of Rails applications on JRuby. I try following all of your
> blogs but I'm not sure what is the recommended setup. I'm familiar with
> mongrel from MRI, however, I'm not a Java guy. When it comes down to
> Tomcat, GlassFish, etc. what are my best (from performance to simplicity)
> options? What are the best options for packaging my applications for
> deployment to these application servers? I have seen mention of goldspike
> and warbler but I am not sure which I should be using.

To be honest, I'm as confused as you are. There's a massive
simplification that needs to happen somewhere. Warbler has helped a lot
though, and it's being used internally by Sun to package Rails apps as
WAR files. I'd expect the Warbler approach is most people will want to
follow in the future.

What we really need is this kind of feedback, to smack the GoldSpike and
Warbler people around and let them know "this is getting too
complicated". You should pass that along on the JRuby or JRuby-Extras
mailing lists (and if you have any ideas, you should offer them...even
if you don't think you're qualified. The "Java way" is very often the
wrong way.)