SlideShare a Scribd company logo
JRuby in Action




                Ruby, Rails, GUIs, and More




Except where otherwise noted, the content of this presentation is licensed under 
the Creative Commons Attribution­Share Alike 3.0 United States License (http://creativecommons.org/licenses/by­sa/3.0/us/).
The JRuby Guys
●   Charles Oliver Nutter and Thomas Enebo
●   JRuby for 4+ years
●   Sun Microsystems for 2+ years
●   JVM languages
Ruby
●   Dynamically typed
●   Pure object-oriented
●   C-language implementation
    ●   Green threads
    ●   “Fast enough” == “a bit slow”
●   1.8.6/7 is current
●   1.9 in development
    ●   Focus on performance, character encodings
JRuby
●   Ruby on the JVM
●   Nearly complete Ruby compatibility
●   Interop with Java libraries
●   Improvements on original
    ●   Native threading
    ●   Faster by most measurements
●   1.1.6 this week (RC1 out now)
●   1.8.6 compatible, 1.9 in progress
Ruby Tutorial
●   Walkthrough of all the key Ruby features
●   Interactive! Please jump in with questions
●   Free-form, live-coded
●   Ruby is fun, Ruby tutorial should be fun!
Modules

             Object




          MyGreatClass



class MyGreatClass < Object
 …
end
Modules
             Object




         MyGreatModule




          MyGreatClass




class MyGreatClass < Object
 include MyGreatModule
end
Modules
                                   Class
                                   class



   Object                       Object
   class                       meta class



MyGreatClass                  MyGreatClass
   class                       meta class



     class MyGreatClass < Object
      extend MyGreatModule
     end
Modules
                                Object
   Object
                               Meta class




                             MyGreatModule




                              MyGreatClass
MyGreatClass
                               Meta class



     class MyGreatClass < Object
      extend MyGreatModule
     end
Singletons

                               Object




my_object                MyGreatClass




class MyGreatClass
end

my_object = MyGreatClass.new
Singletons
                               Object




                         MyGreatClass




                         MyGreatClass
my_object
                         singleton class


class MyGreatClass
end

my_object = MyGreatClass.new
class << my_object
end
More Cool Ruby: FFI
●   Foreign Function Interface
●   Call C libraries from Ruby code
●   Works on Ruby and JRuby
●   Map simple types, structs, callbacks
●   DSL for function binding
JVMScript (working title)
●   A DSL for generating JVM bytecode
●   Multiple Ruby techniques employed
●   Goal: structured assembly for JVM
What is Ruby on Rails?
●   A Full-stack MVC web development framework
●   Open Source (MIT), Many Contributors
●   Written in Ruby
●   Single-Threaded design (2.2 has MT-mode)
●   First released in 2004 by David Heinemeier Hansson
●   Super-hyped! :)   :(
Rails Precepts
●   Convention over Configuration
    ●   Why punish the common cases?
    ●   Encourages standard practices
    ●   Everything simpler and smaller
●   Don't Repeat Yourself (DRY)
    ●   Framework written around minimizing repetition
    ●   Repetitive code harmful to adaptability
●   Agile Development Environment
    ●   No recompile, deploy, restart cycles
    ●   Simple tools to generate code quickly
    ●   Testing built into framework
Why Rails?
●   Greatly simplified web development
    ●   “Less Rails code than Java app configuration”
    ●   Instant applications: working code in minutes
●   Makes small apps trivial to create
●   Ruby is an excellent language
●   Still growing in popularity in leaps and bounds
The Rails Stack
●   ActiveRecord
    ●   ORM on steroids
●   ActionPack
    ●   View and controller support
●   ActiveResource
    ●   Restful resources
●   Actionmailer
    ●   Email
●   Activesupport
    ●   Unicode, json, miscellaneous helpers
Rails Demo




Let's write a simple blog app
JRuby on Rails
●   Java is Everywhere
    ●   Every OS/Hardware platform you can think of
    ●   Probably already on a server near you
●   Less political resistance
    ●   “JRuby is just another Jar file”
    ●   No need to install additional software on your servers
●   Wider database support
●   Decent performance
JRuby on Rails (Warbler)
●   Java-style deployment to Application Server
●   Bundles a Rails application into a WAR file
●   Hand WAR file to production staff
●   Rails App deployed!

                                          Rack




       http://wiki.jruby.org/wiki/JRuby_Rack
JRuby on Rails (GlassFish v3 gem)
●   Entire App Server in a 4Mb gem
●   Ruby-style deployment to GF Application Server
    ●   gem install glassfish
    ●   glassfish <Rails app dir>
●   Configurable number of listeners all in one process
●   Under active development



                                            GlassFish
Parts is Parts
●   Script Java technology you need into your Rails app
    ●   Call “legacy” Java from existing project
    ●   Get additional choices
Swing GUI in JRuby
●   Builder approach (ex: Rubeus)
    ●   Sort of a “model 1” 1998 JSP approach
    ●   Great for simple forms
    ●   Difficult for long-term, large apps
●   Tool-driven approach (ex: MonkeyBars)
    ●   Tool manages UI layout
    ●   Logic is MVC-driven
    ●   UI and logic evolved, maintained separately
    ●   Easier to scale to large apps

More Related Content

PDF
Gluecon 2014 - Bringing Node.js to the JVM
ODP
Web technologies
PDF
Introduction to TypeScript
PDF
JRuby Basics
PDF
Ruby Metaprogramming 08
PPTX
Nodejs
PDF
Kaunas JUG#1: Java History and Trends (Dainius Mezanskas)
PDF
Dsl로 만나는 groovy
Gluecon 2014 - Bringing Node.js to the JVM
Web technologies
Introduction to TypeScript
JRuby Basics
Ruby Metaprogramming 08
Nodejs
Kaunas JUG#1: Java History and Trends (Dainius Mezanskas)
Dsl로 만나는 groovy

What's hot (20)

PDF
JavaScript Roadmap III - ECMAScript
PDF
Javantura 2014 - Java 8 JavaScript Nashorn
PDF
JRuby - Programmer's Best Friend on JVM
PDF
Node.js Course 1 of 2 - Introduction and first steps
PDF
Node.js an Exectutive View
PDF
Node.js Course 2 of 2 - Advanced techniques
PPTX
Introduction to node.js
PPTX
React web development
PPTX
Java (advanced and core)online training in Hyderabad|course content
ODP
TypeScript
PPTX
Node js crash course session 1
KEY
Introduction to Java 7 (OSCON 2012)
PPTX
SELF - Becoming a Rails Developer - The Rest of the Story
PPTX
Intro to nodejs
PDF
The Bleeding Edge
PDF
Node.js, toy or power tool?
PDF
Ruby on rails探索
PDF
Porting 100k Lines of Code to TypeScript
PPTX
Green Custard Friday Talk 5: React-Native Performance
PDF
Ruby JIT Compilation - Mykhail Bortnyk
JavaScript Roadmap III - ECMAScript
Javantura 2014 - Java 8 JavaScript Nashorn
JRuby - Programmer's Best Friend on JVM
Node.js Course 1 of 2 - Introduction and first steps
Node.js an Exectutive View
Node.js Course 2 of 2 - Advanced techniques
Introduction to node.js
React web development
Java (advanced and core)online training in Hyderabad|course content
TypeScript
Node js crash course session 1
Introduction to Java 7 (OSCON 2012)
SELF - Becoming a Rails Developer - The Rest of the Story
Intro to nodejs
The Bleeding Edge
Node.js, toy or power tool?
Ruby on rails探索
Porting 100k Lines of Code to TypeScript
Green Custard Friday Talk 5: React-Native Performance
Ruby JIT Compilation - Mykhail Bortnyk
Ad

Viewers also liked (20)

PDF
Circolare 32 21 Giugno 2005
PDF
SW_Documentation_GRASS
PDF
newperl5
PPTX
Using Internet Technology for Learning
PDF
Lecture19-20
PDF
Jdbc中驱动加载的过程分析(上)
PDF
给学习J2 Ee的朋友一些值得研究的开源项目
PDF
sample-06
DOC
Gita Study Nov 9 Dr. Shriniwas J. Kashalikar
PDF
FrontMatter
PDF
Content Outside of CONTENTdm: Part 1: Exhibit Creation Tool using &lt;b>...&l...
PPTX
Receitas com castanhas
PDF
INFS730
PPT
La Investigacion En El Proceso
PDF
ruby-cocoa
PDF
ruby_vs_perl_and_python
PPTX
Viral Marketing v praxi by ZARAGUZA .Com
PDF
Dojo1.0_Tutorials
PDF
PCCNews0609
PDF
netbeans
Circolare 32 21 Giugno 2005
SW_Documentation_GRASS
newperl5
Using Internet Technology for Learning
Lecture19-20
Jdbc中驱动加载的过程分析(上)
给学习J2 Ee的朋友一些值得研究的开源项目
sample-06
Gita Study Nov 9 Dr. Shriniwas J. Kashalikar
FrontMatter
Content Outside of CONTENTdm: Part 1: Exhibit Creation Tool using &lt;b>...&l...
Receitas com castanhas
INFS730
La Investigacion En El Proceso
ruby-cocoa
ruby_vs_perl_and_python
Viral Marketing v praxi by ZARAGUZA .Com
Dojo1.0_Tutorials
PCCNews0609
netbeans
Ad

Similar to Devoxx%202008%20Tutorial (20)

PDF
Ruby for C#-ers (ScanDevConf 2010)
PDF
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
PDF
The Joy Of Ruby
PDF
Ruby On Rails pizza training
PDF
IJTC%202009%20JRuby
PDF
IJTC%202009%20JRuby
KEY
Ruby on Rails Training - Module 1
PDF
Connecting the Worlds of Java and Ruby with JRuby
PPT
Java, Ruby & Rails
ZIP
Meta Programming in Ruby - Code Camp 2010
PPTX
Why Ruby?
PDF
When To Use Ruby On Rails
PDF
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
KEY
A tour on ruby and friends
PDF
Web Development using Ruby on Rails
PDF
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
PPT
Rapid Application Development using Ruby on Rails
PDF
Ruby an overall approach
PDF
JRuby, Ruby, Rails and You on the Cloud
KEY
Ruby on Rails survival guide of an aged Java developer
Ruby for C#-ers (ScanDevConf 2010)
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
The Joy Of Ruby
Ruby On Rails pizza training
IJTC%202009%20JRuby
IJTC%202009%20JRuby
Ruby on Rails Training - Module 1
Connecting the Worlds of Java and Ruby with JRuby
Java, Ruby & Rails
Meta Programming in Ruby - Code Camp 2010
Why Ruby?
When To Use Ruby On Rails
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
A tour on ruby and friends
Web Development using Ruby on Rails
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Rapid Application Development using Ruby on Rails
Ruby an overall approach
JRuby, Ruby, Rails and You on the Cloud
Ruby on Rails survival guide of an aged Java developer

More from tutorialsruby (20)

PDF
&lt;img src="../i/r_14.png" />
PDF
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>
PDF
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>
PDF
&lt;img src="../i/r_14.png" />
PDF
&lt;img src="../i/r_14.png" />
PDF
Standardization and Knowledge Transfer – INS0
PDF
xhtml_basics
PDF
xhtml_basics
PDF
xhtml-documentation
PDF
xhtml-documentation
PDF
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
PDF
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
PDF
HowTo_CSS
PDF
HowTo_CSS
PDF
BloggingWithStyle_2008
PDF
BloggingWithStyle_2008
PDF
cascadingstylesheets
PDF
cascadingstylesheets
&lt;img src="../i/r_14.png" />
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>
&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />
Standardization and Knowledge Transfer – INS0
xhtml_basics
xhtml_basics
xhtml-documentation
xhtml-documentation
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
HowTo_CSS
HowTo_CSS
BloggingWithStyle_2008
BloggingWithStyle_2008
cascadingstylesheets
cascadingstylesheets

Recently uploaded (20)

PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
A novel scalable deep ensemble learning framework for big data classification...
PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PPTX
A Presentation on Artificial Intelligence
PPTX
TLE Review Electricity (Electricity).pptx
PPTX
A Presentation on Touch Screen Technology
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
August Patch Tuesday
PDF
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
PDF
Getting Started with Data Integration: FME Form 101
PDF
Mushroom cultivation and it's methods.pdf
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
A comparative analysis of optical character recognition models for extracting...
A novel scalable deep ensemble learning framework for big data classification...
SOPHOS-XG Firewall Administrator PPT.pptx
A Presentation on Artificial Intelligence
TLE Review Electricity (Electricity).pptx
A Presentation on Touch Screen Technology
Building Integrated photovoltaic BIPV_UPV.pdf
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
Encapsulation_ Review paper, used for researhc scholars
MIND Revenue Release Quarter 2 2025 Press Release
August Patch Tuesday
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
Getting Started with Data Integration: FME Form 101
Mushroom cultivation and it's methods.pdf
Assigned Numbers - 2025 - Bluetooth® Document
Digital-Transformation-Roadmap-for-Companies.pptx
From MVP to Full-Scale Product A Startup’s Software Journey.pdf

Devoxx%202008%20Tutorial

  • 1. JRuby in Action Ruby, Rails, GUIs, and More Except where otherwise noted, the content of this presentation is licensed under  the Creative Commons Attribution­Share Alike 3.0 United States License (http://creativecommons.org/licenses/by­sa/3.0/us/).
  • 2. The JRuby Guys ● Charles Oliver Nutter and Thomas Enebo ● JRuby for 4+ years ● Sun Microsystems for 2+ years ● JVM languages
  • 3. Ruby ● Dynamically typed ● Pure object-oriented ● C-language implementation ● Green threads ● “Fast enough” == “a bit slow” ● 1.8.6/7 is current ● 1.9 in development ● Focus on performance, character encodings
  • 4. JRuby ● Ruby on the JVM ● Nearly complete Ruby compatibility ● Interop with Java libraries ● Improvements on original ● Native threading ● Faster by most measurements ● 1.1.6 this week (RC1 out now) ● 1.8.6 compatible, 1.9 in progress
  • 5. Ruby Tutorial ● Walkthrough of all the key Ruby features ● Interactive! Please jump in with questions ● Free-form, live-coded ● Ruby is fun, Ruby tutorial should be fun!
  • 6. Modules Object MyGreatClass class MyGreatClass < Object … end
  • 7. Modules Object MyGreatModule MyGreatClass class MyGreatClass < Object include MyGreatModule end
  • 8. Modules Class class Object Object class meta class MyGreatClass MyGreatClass class meta class class MyGreatClass < Object extend MyGreatModule end
  • 9. Modules Object Object Meta class MyGreatModule MyGreatClass MyGreatClass Meta class class MyGreatClass < Object extend MyGreatModule end
  • 10. Singletons Object my_object MyGreatClass class MyGreatClass end my_object = MyGreatClass.new
  • 11. Singletons Object MyGreatClass MyGreatClass my_object singleton class class MyGreatClass end my_object = MyGreatClass.new class << my_object end
  • 12. More Cool Ruby: FFI ● Foreign Function Interface ● Call C libraries from Ruby code ● Works on Ruby and JRuby ● Map simple types, structs, callbacks ● DSL for function binding
  • 13. JVMScript (working title) ● A DSL for generating JVM bytecode ● Multiple Ruby techniques employed ● Goal: structured assembly for JVM
  • 14. What is Ruby on Rails? ● A Full-stack MVC web development framework ● Open Source (MIT), Many Contributors ● Written in Ruby ● Single-Threaded design (2.2 has MT-mode) ● First released in 2004 by David Heinemeier Hansson ● Super-hyped! :) :(
  • 15. Rails Precepts ● Convention over Configuration ● Why punish the common cases? ● Encourages standard practices ● Everything simpler and smaller ● Don't Repeat Yourself (DRY) ● Framework written around minimizing repetition ● Repetitive code harmful to adaptability ● Agile Development Environment ● No recompile, deploy, restart cycles ● Simple tools to generate code quickly ● Testing built into framework
  • 16. Why Rails? ● Greatly simplified web development ● “Less Rails code than Java app configuration” ● Instant applications: working code in minutes ● Makes small apps trivial to create ● Ruby is an excellent language ● Still growing in popularity in leaps and bounds
  • 17. The Rails Stack ● ActiveRecord ● ORM on steroids ● ActionPack ● View and controller support ● ActiveResource ● Restful resources ● Actionmailer ● Email ● Activesupport ● Unicode, json, miscellaneous helpers
  • 18. Rails Demo Let's write a simple blog app
  • 19. JRuby on Rails ● Java is Everywhere ● Every OS/Hardware platform you can think of ● Probably already on a server near you ● Less political resistance ● “JRuby is just another Jar file” ● No need to install additional software on your servers ● Wider database support ● Decent performance
  • 20. JRuby on Rails (Warbler) ● Java-style deployment to Application Server ● Bundles a Rails application into a WAR file ● Hand WAR file to production staff ● Rails App deployed! Rack http://wiki.jruby.org/wiki/JRuby_Rack
  • 21. JRuby on Rails (GlassFish v3 gem) ● Entire App Server in a 4Mb gem ● Ruby-style deployment to GF Application Server ● gem install glassfish ● glassfish <Rails app dir> ● Configurable number of listeners all in one process ● Under active development GlassFish
  • 22. Parts is Parts ● Script Java technology you need into your Rails app ● Call “legacy” Java from existing project ● Get additional choices
  • 23. Swing GUI in JRuby ● Builder approach (ex: Rubeus) ● Sort of a “model 1” 1998 JSP approach ● Great for simple forms ● Difficult for long-term, large apps ● Tool-driven approach (ex: MonkeyBars) ● Tool manages UI layout ● Logic is MVC-driven ● UI and logic evolved, maintained separately ● Easier to scale to large apps