JRuby Whirlwind Tour
            Ola Bini
     JRuby Core Developer
     ThoughtWorks Studios
About me

• Ola Bini
• From Stockholm, Sweden
• Works for ThoughtWorks Studios in London
• Programming language nerd
What is JRuby
• Java implementation of the Ruby language
 • Current version 1.0
 • Based on Ruby 1.8.5
• Started in 2001
 ...
Why JRuby?
• Performance
• Native threading
• Native Unicode support
• Interpreted, compiled, mixed-mode, AOT, JIT
• Java ...
Demo:
Interactive JRuby
Compatibility
• Ruby has no official specification
• ... and no complete suite of tests
• We take what’s available for JRuby...
JRuby runtime modes
• Interpreted
 • Standard mode, fully implemented
• Compilation
 • Not complete yet
 • AOT
 • JIT - Ho...
JRuby on Rails

• JRuby runs Rails very well
• Improved deployment story
• JDBC database connections
• Performance
• Integ...
ActiveRecord-JDBC

• ActiveRecord adapter for JDBC drivers
• Supports MySQL, Postgres, Oracle, Derby,
  MS SQL Server, HSQ...
Goldspike
• Support for packaging and serving Rails
  WAR files
• Rails plugin, adds Rake tasks
• Includes a RailsServlet
•...
Demo?
JRuby on Rails
Mingle
• Agile Project Intelligence
• First commercial JRuby on Rails application
• Originally choose JRuby for SVN plugin...
Mingle+JRuby lessons
• Mingle was originally developed in MRI
• A LARGE test suite helps the migration
• Running the Mingl...
YARV
• Yet Another Ruby VM
• Ruby 2.0
• JRuby have a simple YARVMachine
• JRuby also have a simple YARV compiler
• Work go...
Rubinius
• JRuby has a simple Rubinius machine
• Not support for all Rubinius bytecodes
• Why
 • Compatibility
 • Experime...
Testing
• RSpec
• RBehave
• Test::Unit
• Mocha
• All works fine on JRuby
• ... and can be used on Java classes too
Swing
• Cheri
 • By JRuby Core Developer Bill Dortch
 • Nice Ruby wrapper around Swing
• Profligacy
 • By Zed Shaw
 • Uses ...
Profligacy example

[ label_1         | label3       ]
[ (300,300)*text1 | (150)people ]
[ <label2         |_            ]
...
Rubiq

• Lisp layer on top of JRuby
• Transforms to JRuby AST
• ... and lets JRuby execute it
• Rubiq is _very_ new (three...
Rubiq features
• Macros
• Read macros (used to implement regexp
  syntax, for example)
• Pure lexical scoping
• Lambdas tr...
Under the hood
• JRuby::ast_for(“1+1”) #-> Java AST
• JRuby::ast_for { 1+1 } #-> Java AST
• JRuby::compile(“1+1”) #-> Comp...
A JRuby future
• Ruby objects right now descends from
  org.jruby.RubyObject
• Planning to make most of the lightweight
  ...
24 September, ‘07
Resources
• JRuby: www.jruby.org
• ThoughtWorks Studios:
  studios.thoughtworks.com
• Profligacy: ihate.rubyforge.org
• JRu...
?
Upcoming SlideShare
Loading in...5
×

J Ruby Whirlwind Tour

2,460

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,460
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Transcript of "J Ruby Whirlwind Tour"

  1. 1. JRuby Whirlwind Tour Ola Bini JRuby Core Developer ThoughtWorks Studios
  2. 2. About me • Ola Bini • From Stockholm, Sweden • Works for ThoughtWorks Studios in London • Programming language nerd
  3. 3. What is JRuby • Java implementation of the Ruby language • Current version 1.0 • Based on Ruby 1.8.5 • Started in 2001 • Currently 6 core developers • Open Source, about 30 contributors • ThoughtWorks offers commercial support
  4. 4. Why JRuby? • Performance • Native threading • Native Unicode support • Interpreted, compiled, mixed-mode, AOT, JIT • Java library integration (JDBC, XML, etc) • Enterprise acceptance
  5. 5. Demo: Interactive JRuby
  6. 6. Compatibility • Ruby has no official specification • ... and no complete suite of tests • We take what’s available for JRuby • Existing suites (BFTS, Rubicon, ruby_test) • Our own suite • Other tests (Rubinius) • Application test suites (RSpec, Rails, RubyGems)
  7. 7. JRuby runtime modes • Interpreted • Standard mode, fully implemented • Compilation • Not complete yet • AOT • JIT - Hot swap method implementations
  8. 8. JRuby on Rails • JRuby runs Rails very well • Improved deployment story • JDBC database connections • Performance • Integrate with Java infrastructure
  9. 9. ActiveRecord-JDBC • ActiveRecord adapter for JDBC drivers • Supports MySQL, Postgres, Oracle, Derby, MS SQL Server, HSQLDB, and more • Easy to add new databases
  10. 10. Goldspike • Support for packaging and serving Rails WAR files • Rails plugin, adds Rake tasks • Includes a RailsServlet • Can deploy to any compliant Java application server • Can run directly with embedded Jetty
  11. 11. Demo? JRuby on Rails
  12. 12. Mingle • Agile Project Intelligence • First commercial JRuby on Rails application • Originally choose JRuby for SVN plugins • Later used JRuby for: • Derby (embedded Java database) • Protecting source code • Easy bundling
  13. 13. Mingle+JRuby lessons • Mingle was originally developed in MRI • A LARGE test suite helps the migration • Running the Mingle test suite under JRuby is slightly slower than on MRI • ... but the actual application performs and scales better • Java Integration is MUCH easier than C extensions
  14. 14. YARV • Yet Another Ruby VM • Ruby 2.0 • JRuby have a simple YARVMachine • JRuby also have a simple YARV compiler • Work going on to replace interpreted mode with YARV interpretation instead
  15. 15. Rubinius • JRuby has a simple Rubinius machine • Not support for all Rubinius bytecodes • Why • Compatibility • Experimentation • Alternative to YARV for interpretation?
  16. 16. Testing • RSpec • RBehave • Test::Unit • Mocha • All works fine on JRuby • ... and can be used on Java classes too
  17. 17. Swing • Cheri • By JRuby Core Developer Bill Dortch • Nice Ruby wrapper around Swing • Profligacy • By Zed Shaw • Uses ASCII-pictures create layouts (LEL)
  18. 18. Profligacy example [ label_1 | label3 ] [ (300,300)*text1 | (150)people ] [ <label2 |_ ] [ message | buttons ]
  19. 19. Rubiq • Lisp layer on top of JRuby • Transforms to JRuby AST • ... and lets JRuby execute it • Rubiq is _very_ new (three days) • But will soon provide several interesting stuff
  20. 20. Rubiq features • Macros • Read macros (used to implement regexp syntax, for example) • Pure lexical scoping • Lambdas transparently transforms to blocks or Proc.new depending on location • Will not support most Ruby syntax • Principle of least Lisp-surprise
  21. 21. Under the hood • JRuby::ast_for(“1+1”) #-> Java AST • JRuby::ast_for { 1+1 } #-> Java AST • JRuby::compile(“1+1”) #-> CompiledScript • CompiledScript.inspect_bytecode • JRuby::runtime • JRuby::reference(“str”)
  22. 22. A JRuby future • Ruby objects right now descends from org.jruby.RubyObject • Planning to make most of the lightweight objects with behavior attached • Finish the compiler • Make YARV or Rubinius standard interpretation • Focus on surrounding projects
  23. 23. 24 September, ‘07
  24. 24. Resources • JRuby: www.jruby.org • ThoughtWorks Studios: studios.thoughtworks.com • Profligacy: ihate.rubyforge.org • JRuby-extras: jruby-extras.rubyforge.org • Rubiq: rubiq.googlecode.com • My blog: ola-bini.blogspot.com
  25. 25. ?

×