Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I am in the research phase of a project that needs to make use of 3rd party libraries that are in Java so I am stuck using Java to at least a small degree.

I am considering implementing Ruby as the front-end layer. That would leave me with the option of calling the Java classes as a web service by hitting a certain URL, is that correct?

Is that generally a solid approach to things?

Also, how would it affect my build environment when I create the .war file using Ant? should I have src/java and src/ruby code, or do the ruby files go somewhere else?

Any tips and pitfalls on this? I am a little bit new to Ruby so advice would be appreciated.

Also, I considered JRuby, but it seemed like a less mature tool that just has a JVM for a smoother calling of Java classes, correct? I am concerned with the maturity of that tool and its bein neither Java nor Ruby.

share|improve this question
    
"its bein neither Java nor Ruby"? JRuby is Ruby. –  Rein Henrichs Apr 20 '11 at 16:29
    
@Rein but then why is it JRuby and not Ruby? lol ...from reading about it I got the sense that it is a separate thing from Ruby. –  Genadinik Apr 20 '11 at 16:32
    
it's a different implementation of Ruby. –  Rein Henrichs Apr 20 '11 at 16:43
3  
JRuby is a compatible implementation of the Ruby language that runs on the Java Virtual Machine--which means it is subject to all the optimizations that the Hot Spot VM does for you. It's been shown to run faster than Ruby 1.8 (interpreted C based runtime). –  Berin Loritsch Apr 20 '11 at 16:44
    
So if it is a different implementation, should I expect random quirks with it? My concern is that it is a fragmented subset of a tool which will be a pain when it comes to random errors and configuration differences, with smaller community to rely on for help. –  Genadinik Apr 20 '11 at 16:48
add comment

2 Answers 2

JRuby is quite mature now, has a hell of a better performance than the official Ruby runtime (if you target Ruby 1.8.x; the 1.9.x branch impoved a lot, and makes performance differences between the 2 less relevant), and gives you very easy access to Java libraries.

Plus, if you way that you want to package WAR files then I guess it wouldn't be an issue for you to use a Java-enabled container/server.

So, I would definitely recommend that you get a closer look at JRuby.

And no, JRuby doesn't "have a JVM". It runs on top of a JVM. So you can develop your whole project in JRuby if you want (or even code it with Ruby and then call your code using JRuby, though you might encounter a few surprises so I'd recommend to use JRuby from the beginning) and just use the Java classes whenever you need to.

It's fairly well integrated, it has a lively and friendly community, and they produce regular updates to the implementation.

Regarding you build environment, if you use JRuby you will be able to call the compiler from Ant easily (like anything else, really), so that wouldn't be an issue. There might even be some custom tasks already implemented, I don't really know the state of things in this area.


Personal experience anecdotes and stuff: I used JRuby a lot for implementing automated test harness a few years back (mostly around 2007) and it wasn't even that mature at the time, and yet it was already in my opinion a much better alternative over the official Ruby implementation. Plus it was great in my case that it run on the JVM as I could also use it to unit test Java classes. And it's been improving steadily over time.

Its only disadvantage is that, if you use it to develop small programs or standalone tools, that you need to package your solution with a JVM or have the user install one, and that for short-lived programs the cost of firing up a JVM (especially older versions, it's quite fine now) might be a drag.

Apart from that, that was a very good solution and I still write scripts on it occasionally.

share|improve this answer
add comment

A word of caution: Native gems (those that require C extensions) cannot be used with JRuby. Gems written in Ruby only will work with JRuby.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.