Question

Recently I have coded a application in jruby and made .jar file from it and deployed same in tomcat. I have also read an article on jruby which says "Jruby- scalablity of java and easiness of ruby".

Here I want to know does coding like this in jruby, give same scalability and performance like directly coding in java?

Just like this using ruby extension to run c code in ruby gives same performance as directly coding in c.

Thanks

Was it helpful?

Solution

(Disclaimer: this might not be a complete answer but it was too long for a comment)

Although I have next to no experience with JRuby's implementation in particular, dynamic languages implemented on the JVM have their limitations in terms of the speed you can get compared to what you would get if you coded directly in Java.

From what I understand, this comes from the trade-offs client language implementations (JRuby, Clojure, Jython, etc.) have to make, in order to "simulate" their inner workings on the host platform (in this case the JVM). Maybe in the most common scenarios the performance difference is not that bad since the JVM's HotSpot optimizations kick in, but when it comes down to getting Java-like code performance, you might need to dive into the details of the language implementation in order to bypass some of its limitations.

In the case of the Ruby extensions in C, what you are actually executing is native code (machine language) that was originally coded in C, but which you can call from your Ruby code. When running JRuby code, the language you are programming in is Ruby, which has to be compiled to Java bytecode, which runs on the JVM, which translates that into operations in the native operating system. Something analog to Ruby/C would be in this case JRuby/Java, that would be calling some Java code, that was originally written in Java from your JRuby program.

EDIT

This discussion mentions some of the points I have included above and a more detailed explanation on some other interesting points.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top