[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Talking more about JRuby

Charles Oliver Nutter

10/28/2007 6:45:00 AM

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

29 Answers

M. Edward (Ed) Borasky

10/28/2007 7:01:00 AM

0

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?

Charles Oliver Nutter

10/28/2007 7:23:00 AM

0

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_...
http://blogs.sun.com/coolstuff/entry/using_java_classe...

> 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

10/28/2007 3:36:00 PM

0


On Oct 28, 2007, at 2:45 AM, Charles Oliver Nutter 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?

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



Charles Oliver Nutter

10/28/2007 4:38:00 PM

0

Ari Brown wrote:
>
> On Oct 28, 2007, at 2:45 AM, Charles Oliver Nutter 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

Charles Oliver Nutter

10/28/2007 5:10:00 PM

0

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

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+inter... 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_Inter...

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

James Britt

10/28/2007 5:26:00 PM

0

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

Charles Oliver Nutter

10/28/2007 5:43:00 PM

0

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

Konrad Meyer

10/28/2007 7:17:00 PM

0

Quoth Charles Oliver Nutter:
> ...
> http://java.sun.com/j2se/1.5.0/docs/api/...
> ...

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

Charles Oliver Nutter

10/28/2007 8:33:00 PM

0

Konrad Meyer wrote:
> Quoth Charles Oliver Nutter:
>> ...
>> http://java.sun.com/j2se/1.5.0/docs/api/...
>> ...
>
> 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

James Britt

10/28/2007 9:14:00 PM

0

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

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