Date post: | 15-May-2015 |
Category: |
Business |
Upload: | amit-solanki |
View: | 2,146 times |
Download: | 0 times |
Problems with Ruby
• Green threading• No scaling across processors
• Partial Unicode support• Internet connected application needs solid unicode support• No native support for unicode or multibyte string• Rails 1.2 introduced ActiveSupport:Multibyte
• Performance• Interpreted not compiled• Ruby considered “fast enough”• ... but routinely finishes last in benchmark• ... and no work being done in 1.8 to improve
Features missing from Java
• Closures
• Open classes and metaprogramming
• Array, Hash, Regexp literals
• Duck-typing
Introduction to JRuby
• 100% pure java implementation of ruby• current version 1.1 RC 1• based on ruby 1.8.6 (MRI)
• Originally created by Jan Arne Petersen, in 2001• direct port of ruby 1.6 C code
• Developed by JRuby Team• 6 core developers right now• open source developers• full support from Sun Microsystems
Features
• Running on JVM provides• Native threads• Unicode Support• Portability
• Most builtin ruby classes provided• Wide variety of GC options
• Concurrent• Generational• Real-time
• Scalability with native threading(Ruby Thread <=> Java Thread)
• assign work to multiple processors
• better performance at I/O & context-switching operations
Features (contd...)
• Support with interacting with and defining java classes from within ruby• full two way access between the two
• Interpreted, compiled and mixed mode Bean Scripting Framework (BSF) support
• Distributed under tri-license (CPL/GPL/LGPL)
• Support for rubygems, mongrel and (J)Ruby on Rails
• Domain Specific Language (DSL)
JRuby Compiler
• Ahead Of Time (AOT)• compile .rb file to .class file• directly executable, or require/loadable
• Just In Time (JIT)• heavily hit methods compiled at runtime• run existing applications, scripts without modification• optimize methods generated at runtime
• Incremental design• fall back on interpreter for unimplemented bits
Demo
Example
hello_world.rb
Example
testJava.rb
Example
bench_fib_recursive.rb
Comparison:JRuby vs Ruby
jruby bench_fib_recursive.rb
CPU time ¦ System CPU time ¦ Sum of the user and system CPU times ¦ (Elapsed real time)
1.622000 0.000000 1.622000 (1.579000)1.511000 0.000000 1.511000 (1.511000)
ruby bench_fib_recursive.rb
CPU time ¦ System CPU time ¦ Sum of the user and system CPU times ¦ (Elapsed real time)
1.640000 0.010000 1.650000 (1.652467)1.650000 0.000000 1.650000 (1.655654)
Performance & Stability
• JRuby 1.1 - fastest way to run Ruby 1.8 & Rails
• Better garbage collection mechanism
• Dynamic optimization
• Mix-mode virtual machine: compiled JRuby• JRuby Compiler
• Mode:• Interpret• Just-in-time (JIT)• Ahead-of-time (AOT)
Use Cases
• Scripting• JVM too long to start• console clunky when jruby and ruby used together
• Client-side application• app runs long enough• swings getting pretty fast
• Server-side application• server JVM optimizes app at runtime• lots of great servers: Glassfish, JBoss, Oracle, Tomcat, Jetty ...• great monitoring tools• deployment via WAR file
Downsides
• Slow development
• Not enough documentation
• Missing POSIX methods• filesytem support (symlinks, stats, chmod, chown)• process control• JNA library + JRuby = True POSIX
• Database support• ActiveRecord-JDBC still needs more work
• Rmagick support is in progress
• Ruby C extensions, system calls
• Does not support continuations/binding
Core Developers
• Charles Oliver Nutter (Sun Microsystens)http://headius.blogspot.com
• Thomas Enebo (Sun Microsystems)http://www.bloglines.com/blog/ThomasEEnebo/
• Nick Sieger (Sun Microsystems)http://blog.nicksieger.com/
• Ola Bini(Thoughtworks)http://ola-bini.blogspot.com/
• Marcin Mielzynski
• Bill Dortch
Live Implementions
• Media Cast - A media file hosting applicationhttp://mediacast.sun.com/
• Sonar - A free enterprise quality control tool for Java projectshttp://sonar.hortis.ch/
• Mingle - A project collaboration and management tool for Agile software development (Webserver: Jetty & DB Server: Derby)http://studios.thoughtworks.com/mingle-project-intelligence
• SpringBook - Web application to publish your springnote to websitehttp://springbook.playmaru.net/?lang=en
• Openwferu - Open source ruby workflow and BPM enginehttp://openwferu.rubyforge.org/aq.html
• Oracle Mixhttps://mix.oracle.com/
Thank You
(-: