Could the Java Platform be the a major helper in order to help Ruby apps to scale more easily?
The Java VM is multi language since its conception, as its runs above the called Java bytecodes which is the needed layer of indirection between it's languages and the VM, with the compilers the actors needed to fill in the gap.
Many years before now we could play with so many languages that compiled to the JVM. I hope JRuby and JPython communities keep up with their great work a take advantage of such mature and sophisticated JVMs we have (available for free) nowadays!
Ruby and JRuby still generate a lot of enthusiasm. More and more Ruby programmers are looking at JRuby as their Ruby projects mature — when they move into heavier loads, larger systems, more cores, more processors. Most significantly, as Ruby development branches out into larger enterprises where deployment on Java servers is important, JRuby is seen as the solution.
A less obvious advantage to JRuby is that it may already be a better Ruby implementation. Certainly that's where it's headed — faster, better use of memory, better use of resources. Many Ruby programmers are starting to see these advantages.
So, people are beginning to understand that whether it's based on Java or the standard implementation, JRuby is better at handling resources, better at taking advantage of multi-core processors, and so on. This is the impetus for people to try JRuby, and to stay with it once they've tried it.It's really sad that most people simply ignore the fact that the Java Virtual Machine supports multiple language for so many years now.
The Java VM is multi language since its conception, as its runs above the called Java bytecodes which is the needed layer of indirection between it's languages and the VM, with the compilers the actors needed to fill in the gap.
Many years before now we could play with so many languages that compiled to the JVM. I hope JRuby and JPython communities keep up with their great work a take advantage of such mature and sophisticated JVMs we have (available for free) nowadays!
This well written article shows the anoyances on how to use regular Java classes in a JRuby program.
Not only it is really confuse but not well documented (as the author states) with things that should be simple like the differences between bringing the module that provides the bridge to the JVM (isn't it JRuby? Is a bridge needed?)
And more:
Well, these guys unfortunately are still missing this very important point of making a Ruby implementation that runs on the JVM. The very first thing I would try on any language that compiles to the JVM is the integration with regular class files.
But don't get me wrong, I do believe JRuby is a hell of a project and the blog of the author of it is very very interesting. I've a deep respect to such a complex piece of software and the initiative to do so.
Not only it is really confuse but not well documented (as the author states) with things that should be simple like the differences between bringing the module that provides the bridge to the JVM (isn't it JRuby? Is a bridge needed?)
First, of course, it's necessary to bring in the module that provides the bridge to the JVM:
include Java
Some things to note:
* Capitalization is significant.
* This version generates an error, saying a module name is required but a string has been supplied:
include 'java'
* This pre 1.0 form is still out there on some web pages. It doesn't generate any obvious errors, but it doesn't work:
require 'java'
* Quotes are an error in this include statement and in the include_class statement. But they're required in the require statement, which comes between them. The mnemonic is "Quotes are required, not included."
The program then needed to require every jar file that the program eventually used, even if it wasn't directly referenced in the JRuby script.
And more:
Accessing External Classes
So far, so good. But somehow I couldn't find quite enough information on the web to access 3rd party classes. After examining the writeups listed in the Resources and doing a lot of experimenting, I was able to make things work by doing the following:
1. Tell JRuby where to find the JAR files. Options:
1. Put them in the CLASSPATH (did not work for me. JRuby didn't seem to read the environment)
2. Put them in $RUBY_HOME/lib (haven't tried this)
3. For NetBeans on Windows, in JRUBY_EXTRA_CLASSPATH (also didn't work for me)
4. Give up and specify the jar files with a full path, as I did in Step #2.
5. Follow the example Rob Di Marco's example and put -Ion the command line for every directory that contains a jar file.
Well, these guys unfortunately are still missing this very important point of making a Ruby implementation that runs on the JVM. The very first thing I would try on any language that compiles to the JVM is the integration with regular class files.
But don't get me wrong, I do believe JRuby is a hell of a project and the blog of the author of it is very very interesting. I've a deep respect to such a complex piece of software and the initiative to do so.
