Talking more about JRuby

  • Thread starter Charles Oliver Nutter
  • Start date
C

Charles Oliver Nutter

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
 
M

M. Edward (Ed) Borasky

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?
 
C

Charles Oliver Nutter

M. Edward (Ed) Borasky said:
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
 
A

Ari Brown

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?

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

Charles Oliver Nutter

Ari said:
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
 
C

Charles Oliver Nutter

Michael said:
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 :) It's been a long hard process, but we're finally starting
to meet many of our longer-term goals.

- Charlie
 
J

James Britt

Charles said:
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
 
C

Charles Oliver Nutter

James said:
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
 
K

Konrad Meyer

--nextPart7462887.Xfq6pcfV6R
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

Quoth Charles Oliver Nutter:

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

Thanks,
=2D-=20
Konrad Meyer <[email protected]> http://konrad.sobertillnoon.com/

--nextPart7462887.Xfq6pcfV6R
Content-Type: application/pgp-signature; name=signature.asc
Content-Description: This is a digitally signed message part.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)

iD8DBQBHJOA4CHB0oCiR2cwRAhTsAKCkR+Gft2GsCTk4GeP54m7G23BorQCfeG52
d7of1t9fbktCIqve6Tc9xgg=
=Tb03
-----END PGP SIGNATURE-----

--nextPart7462887.Xfq6pcfV6R--
 
C

Charles Oliver Nutter

Konrad said:
Quoth Charles Oliver Nutter:

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.

JRuby 1.0 supports 1.4+, and the JRuby 1.1 codebase required 1.5+, but
we will provide a "retroweaved" version that should run fine on 1.4+.

- Charlie
 
J

James Britt

Charles said:
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
 
E

Ezra Zygmuntowicz

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

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
 
R

Robert Klemme

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 said:
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
 
C

Charles Oliver Nutter

Ezra said:
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.

Very nice....we've had a number of people interested in running Merb in
JRuby.

- Charlie
 
C

Charles Oliver Nutter

James said:
That looks pretty much like Rack.

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



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.

That's an excellent idea. I'll make sure Tom knows about it.

- Charlie
 
C

Charles Oliver Nutter

Robert said:
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
 
A

ara.t.howard

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!

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

kind regards

a @ http://codeforpeople.com/
 
N

Nick Sieger

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.)

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]: http://www.headius.com/jrubywiki/index.php/Rails_Integration
 
J

James Britt

ara.t.howard said:
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



--
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
 
C

Charles Oliver Nutter

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

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

I'd like to hear more about it too :) Maybe you could talk a bit about
it here?

- Charlie
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,059
Latest member
cryptoseoagencies

Latest Threads

Top