Introduction to JRuby

2,401 views

Published on

Published in: Business, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
2,401
On SlideShare
0
From Embeds
0
Number of Embeds
34
Actions
Shares
0
Downloads
42
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Introduction to JRuby

  1. 1. JRuby http://www.jruby.org Amit Solanki http://vinsol.com amit@vinsol.com
  2. 2. 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
  3. 3. Features missing from Java • Closures • Open classes and metaprogramming • Array, Hash, Regexp literals • Duck-typing
  4. 4. 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
  5. 5. 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
  6. 6. 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)
  7. 7. 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
  8. 8. Demo
  9. 9. Example hello_world.rb
  10. 10. Example testJava.rb
  11. 11. Example bench_fib_recursive.rb
  12. 12. Comparison: JRuby vs Ruby
  13. 13. 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)
  14. 14. 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
  15. 15. 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
  16. 16. 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
  17. 17. Live Implementions • Media Cast - A media file hosting application http://mediacast.sun.com/ • Sonar - A free enterprise quality control tool for Java projects http://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 website http://springbook.playmaru.net/?lang=en • Openwferu - Open source ruby workflow and BPM engine http://openwferu.rubyforge.org/aq.html • Oracle Mix https://mix.oracle.com/
  18. 18. Thank You (-:

×