I am new to Ruby and the JRuby and I was trying to implement multithreaded code in Ruby and came to know that GIL doesn't allow my code to run in parallel then I moved to JRuby and implemented the same code and my execution time in JRuby was much better than the Ruby. I studied that JRuby threading is very much similar to threading in Java, so I implemented the same in code in Java as well and I got a performance(execution time) in Java to be almost 10x faster than JRuby, can someone explain me the reason for this? Thanks in advance
multithreading in Ruby vs JRuby vs Java
nr: #1 dodano: 2017-12-11 17:12
the explanation is quite simple when you think about JRuby being Ruby implemented in Java, which means that you have 'more' Java code to execute using the .rb piece compared to plain .java compiled to a .class ...
than even if the method dispatch was cost-less there's the dynamic nature of Ruby e.g. when you a+1 on Java it adding to ints while a+1 in Ruby its an addition with overflow checks etc.
your question is quite general and we also do not know what kind of performance measuring you did but in the end it all comes down to productivity when you do 'real-world' work + with JRuby if you feel like some part is worth being 10x faster you still have the option of re-doing that piece in "native" Java.