I believe that JRuby is the most crucial technology for Ruby's future right now. Regardless of how fast or how solid the C or C++ based Ruby implementations get, the vast majority of large organizations are *never* going to run them. That's the truth. If we can leverage JRuby to grab 1-2% of the Java market, we'll *double* the size of the Ruby community. If we completely lose the Java platform to alternatives, Rubyists may not have the luxury of remaining Rubyists in the future. It's that big a deal.
Showing posts with label JRuby. Show all posts
Showing posts with label JRuby. Show all posts
Tuesday, August 4, 2009
Ruby stands or falls with JRuby?
Headius makes an interesting argument
Friday, September 28, 2007
Trying out jrubyc
Following up the good news, I pulled down trunk, and compiled a stupid 2 line script. This obviously is no test of the compiler, but the first time I've used jrubyc. Above and beyond the normal JRUBY environment stuff, to execute classes you have to add jna.jar and jruby.jar to your CLASSPATH.
franz-g4:~/jruby/jruby/trunk/jruby/bin mdfranz$ java bobo
1.1
java
franz-g4:~/jruby/jruby/trunk/jruby/bin mdfranz$ ls -al bobo.class
-rw-r--r-- 1 mdfranz mdfranz 2866 Sep 28 09:43 bobo.class
franz-g4:~/jruby/jruby/trunk/jruby/bin mdfranz$ cat bobo.rb
puts JRUBY_VERSION
puts RUBY_PLATFORM
franz-g4:~/jruby/jruby/trunk/jruby/bin mdfranz$ echo $CLASSPATH
:/Users/mdfranz/java/lib/hsqldb.jar:/Users/mdfranz/java/db-derby-10.3.1.4-bin/lib/derby.jar:/Users/mdfranz/java/db-derby-10.3.1.4-bin/lib/derbytools.jar:.:/Users/mdfranz/jruby/jruby/trunk/jruby/lib/jruby.jar:/Users/mdfranz/jruby/jruby/trunk/jruby/lib/jruby.jar:/Users/mdfranz/jruby/jruby/trunk/jruby/lib/jna.jar
franz-g4:~/jruby/jruby/trunk/jruby/bin mdfranz$ echo $JRUBY_HOME
/Users/mdfranz/jruby/jruby/trunk/jruby
Wednesday, September 26, 2007
If you are angry enough you might get a book!

So I was pleased to learn that I will be receiving a review copy of Practical JRuby on Rails Web 2.0 Projects: Bringing Ruby on Rails to Java. Thanks Ola if you had anything to do with it!
No time (and probably not qualified) right now to do a real review, but I will say that Chapter 6 (Java Integration) and the Appendix B (JRuby Reference) are probably worth the 21 bucks for the e-version of the book, even if you don't plan on doing any JRoR work right now.
Tuesday, September 25, 2007
JRuby Enum Constants and my irrational fear of ::'s
So development on PeerTAB is rolling along. Sort of. I am continuing to play with JXTA via JRuby.
So in Java
manager = new NetworkManager(NetworkManager.ConfigMode.EDGE, "HelloWorld");
But of course in JRuby
include_class "net.jxta.platform.NetworkManager"
m = NetworkManager.new(NetworkManager.ConfigMode.EDGE, "HelloWorld")
fails with
irb(main):010:0> NetworkManager.ConfigMode
NoMethodError: undefined method `ConfigMode' for Java::NetJxtaPlatform::NetworkManager:Class
from (irb):10:in `binding'
from /home/jxta/jruby-1.0.1/lib/ruby/1.8/irb.rb:150:in `eval_input'
from /home/jxta/jruby-1.0.1/lib/ruby/1.8/irb.rb:70:in `signal_status'
from /home/jxta/jruby-1.0.1/lib/ruby/1.8/irb.rb:147:in `eval_input'
from /home/jxta/jruby-1.0.1/lib/ruby/1.8/irb.rb:70:in `each_top_level_statement'
from /home/jxta/jruby-1.0.1/lib/ruby/1.8/irb.rb:146:in `loop'
from /home/jxta/jruby-1.0.1/lib/ruby/1.8/irb.rb:146:in `catch'
from /home/jxta/jruby-1.0.1/lib/ruby/1.8/irb.rb:146:in `eval_input'
from /home/jxta/jruby-1.0.1/lib/ruby/1.8/irb.rb:70:in `start'
from :1:in `catch'
from /home/jxta/jruby-1.0.1/lib/ruby/1.8/irb.rb:69:in `start'
from :1
So the question then I how do I get these enum constants?
So interestingly enough
irb(main):020:0> NetworkManager.constants
=> ["ConfigMode"]
irb(main):021:0>
But that did get me anywhere and it was only until I ran across this blog post that I figured it out.
irb(main):011:0> NetworkManager::ConfigMode
=> Java::NetJxtaPlatform::NetworkManager::ConfigMode
irb(main):012:0> NetworkManager.constants
=> ["ConfigMode"]
irb(main):013:0> NetworkManager.constants.class
=> Array
irb(main):014:0> NetworkManager::ConfigMode::EDGE
=> #
irb(main):015:0>
And I know part of the problem is I refuse to use :: unless I'm forced to because it seems way too Perl-ish and ugly. And yeah, I've heard there is something called C++.
So in Java
manager = new NetworkManager(NetworkManager.ConfigMode.EDGE, "HelloWorld");
But of course in JRuby
include_class "net.jxta.platform.NetworkManager"
m = NetworkManager.new(NetworkManager.ConfigMode.EDGE, "HelloWorld")
fails with
irb(main):010:0> NetworkManager.ConfigMode
NoMethodError: undefined method `ConfigMode' for Java::NetJxtaPlatform::NetworkManager:Class
from (irb):10:in `binding'
from /home/jxta/jruby-1.0.1/lib/ruby/1.8/irb.rb:150:in `eval_input'
from /home/jxta/jruby-1.0.1/lib/ruby/1.8/irb.rb:70:in `signal_status'
from /home/jxta/jruby-1.0.1/lib/ruby/1.8/irb.rb:147:in `eval_input'
from /home/jxta/jruby-1.0.1/lib/ruby/1.8/irb.rb:70:in `each_top_level_statement'
from /home/jxta/jruby-1.0.1/lib/ruby/1.8/irb.rb:146:in `loop'
from /home/jxta/jruby-1.0.1/lib/ruby/1.8/irb.rb:146:in `catch'
from /home/jxta/jruby-1.0.1/lib/ruby/1.8/irb.rb:146:in `eval_input'
from /home/jxta/jruby-1.0.1/lib/ruby/1.8/irb.rb:70:in `start'
from :1:in `catch'
from /home/jxta/jruby-1.0.1/lib/ruby/1.8/irb.rb:69:in `start'
from :1
So the question then I how do I get these enum constants?
So interestingly enough
irb(main):020:0> NetworkManager.constants
=> ["ConfigMode"]
irb(main):021:0>
But that did get me anywhere and it was only until I ran across this blog post that I figured it out.
irb(main):011:0> NetworkManager::ConfigMode
=> Java::NetJxtaPlatform::NetworkManager::ConfigMode
irb(main):012:0> NetworkManager.constants
=> ["ConfigMode"]
irb(main):013:0> NetworkManager.constants.class
=> Array
irb(main):014:0> NetworkManager::ConfigMode::EDGE
=> #
irb(main):015:0>
And I know part of the problem is I refuse to use :: unless I'm forced to because it seems way too Perl-ish and ugly. And yeah, I've heard there is something called C++.
Monday, September 24, 2007
Interesting Bruce Tate Podcast
I listened to Robert Stephenson's interview with Bruce Tate while washing dishes tonight and it was certainly a treat and certainly kept my mind occupied while cleaning up the minestrone remnants:
Among the highlights:
Check it out...
Among the highlights:
- How development in Rails (and I would add comparable frameworks such as Django) allows smaller teams to communicate more effectively (and frequently) with clients than would be possible with "traditional" languages such a Java.
- The high correlation between offshoring/outsourcing and traditional (waterfall) development models (if you outsource something you have to be more rigorous in the your specification, your unit testing, integration, etc.)
- Lots of talk about JRuby and positing that much of the work we do is essentially scripting. Use of JRuby with Business Rules Engines/DSLs (such as Drools) which is something I've wanted to play around with yet. As well as using a Java scripting languages to access cool APIs.
Check it out...
Saturday, September 8, 2007
The Future of Ruby is JRuby?

While fighting with ActiveRecord-JDBC (I thought Derby was built in JDK 1.6, but I still have to copy the derby .jar's into jruby/lib ???) this morning I ran across Ola Bini'a Blog and an a great prezo on JRuby. If you read between the lines (I obviously didn't see/hear the prezo) but Ola seems to be suggesting the future of Ruby is indeed JRuby. Slide after slide there are aspects of C-Ruby that are broken (and will not be fixed in 1.9) but where Java is superior : GC, performance (maybe), multi-core, internationalization, etc.
Sunday, September 2, 2007
JRuby and Embedded Derby: First Steps
Before tackling ActiveRecord-JDBC I thought I'd play around with the embedded version of Apache Derby with JRuby. This actually took me a lot longer that it should of, mostly because its been months since I've done anything with JRuby and years since I've touched JDBC. But here are the basic steps, which probably aren't that much difference from any other JDBC in JRuby:
Some of the things that tripped me up, as I was trying to convert the simple Java example to JRuby:
require 'java'
include_class "java.sql.Connection"
include_class "java.sql.DriverManager"
include_class "java.sql.ResultSet"
include_class "java.sql.Statement"
driver = org.apache.derby.jdbc.EmbeddedDriver.new()
conn = DriverManager.getConnection("jdbc:derby:derbyDB;create=true")
conn.setAutoCommit(false)
s = conn.createStatement()
Some of the things that tripped me up, as I was trying to convert the simple Java example to JRuby:
- The Class.forName(driver).newInstance() nonsense, I guess I've never run across this convention before but probably not surprising since I'm not a Java developer
- org.apache.derby.impl.jdbc.EmbedSQLException: Derby system shutdown - yes you should do a DriverManager.getConnection("jdbc:derby:;shutdown=true") and yes it apparently always throws an exception
- Getting useful results sets back is where I spent most of my time. Fortunately Derby documentation (like most Apache projects) are among of the best of any, whether commercial or Open Source APIs.
Saturday, September 1, 2007
JRuby/Rails on Glassfish Actually Works!
So traffic was so bad on Thursday I popped open my Powerbook on the Edens spur (I swear it took me an hour to go 3 miles) and listened to Java Posse 138 which had a lengthy (but quite excellent interview with several Sun developers from Glassfish. Java Posse is an excellent podcast. I wish there was something of comparable quality on Ruby, but no time for that rant.
Besides the performance improvements (indeed the startup time is quite amazing compared to JBOSS, Geronimo, or Sun's appserver) they mentioned running JRuby apps and I ran across this blog entry on running interpreted rails apps within Glassfish v3 and the Grizzly connector.
I had to make few changes to get it working to Linux-ify the tutorial (had to create a symlink within glassfish/lib to point to the jruby directory) but it was relatively straightforward on Debian 4.0, (JRuby 1.0.1 and jdk1.6.0_02)
Here the slight differences:
I set the environment variables in .bashrc
Install rails (added --no-ri)
Modify glassfish/config/asenv.conf instead of asenv.bat
Make asadmin exectuable (chmod u+x/700)
Besides the performance improvements (indeed the startup time is quite amazing compared to JBOSS, Geronimo, or Sun's appserver) they mentioned running JRuby apps and I ran across this blog entry on running interpreted rails apps within Glassfish v3 and the Grizzly connector.
I had to make few changes to get it working to Linux-ify the tutorial (had to create a symlink within glassfish/lib to point to the jruby directory) but it was relatively straightforward on Debian 4.0, (JRuby 1.0.1 and jdk1.6.0_02)
Here the slight differences:
I set the environment variables in .bashrc
JAVA_HOME=~/jdk6
JRUBY_HOME=~/java/jruby
GLASSFISH_HOME=~/java/glassfish
PATH=$PATH:$JAVA_HOME/bin/:$JRUBY_HOME/bin:$GLASSFISH_HOME/bin
Install rails (added --no-ri)
# jruby -S gem install rails -y --no-ri --no-rdoc
Modify glassfish/config/asenv.conf instead of asenv.bat
JRUBY_HOME="/root/java/jruby"
Make asadmin exectuable (chmod u+x/700)
Saturday, June 9, 2007
Nice Blog on JRuby + JMX
While stumbling around trying to replicate a JXTA Hello world type application in JRuby, I ran across a well-written tutorial by Jeff Mesnil on how to script JMX with JRuby as well a part II.
module JMX
require 'java'
include_class 'java.util.HashMap'
include_package 'java.lang.management'
include_package 'javax.management'
include_package 'javax.management.remote'
url = JMXServiceURL.new "service:jmx:rmi:///jndi/rmi://localhost:3000/jmxrmi"
connector = JMXConnectorFactory::connect url, HashMap.new
mbsc = connector.mbean_server_connection
memory_mbean = ManagementFactory::newPlatformMXBeanProxy mbsc, "java.lang:type=Memory",
MemoryMXBean::java_class
memory_mbean.verbose = !memory_mbean.verbose
puts "verbose = #{memory_mbean.verbose}"
memory_mbean.gc
end
Subscribe to:
Posts (Atom)
