Your SlideShare is downloading. ×
0
JRuby in Action




                Ruby, Rails, GUIs, and More




Except where otherwise noted, the content of this pres...
The JRuby Guys
●   Charles Oliver Nutter and Thomas Enebo
●   JRuby for 4+ years
●   Sun Microsystems for 2+ years
●   JVM...
Ruby
●   Dynamically typed
●   Pure object-oriented
●   C-language implementation
    ●   Green threads
    ●   “Fast enou...
JRuby
●   Ruby on the JVM
●   Nearly complete Ruby compatibility
●   Interop with Java libraries
●   Improvements on origi...
Ruby Tutorial
●   Walkthrough of all the key Ruby features
●   Interactive! Please jump in with questions
●   Free-form, l...
Modules

             Object




          MyGreatClass



class MyGreatClass < Object
 …
end
Modules
             Object




         MyGreatModule




          MyGreatClass




class MyGreatClass < Object
 include...
Modules
                                   Class
                                   class



   Object                    ...
Modules
                                Object
   Object
                               Meta class




                   ...
Singletons

                               Object




my_object                MyGreatClass




class MyGreatClass
end

my...
Singletons
                               Object




                         MyGreatClass




                         My...
More Cool Ruby: FFI
●   Foreign Function Interface
●   Call C libraries from Ruby code
●   Works on Ruby and JRuby
●   Map...
JVMScript (working title)
●   A DSL for generating JVM bytecode
●   Multiple Ruby techniques employed
●   Goal: structured...
What is Ruby on Rails?
●   A Full-stack MVC web development framework
●   Open Source (MIT), Many Contributors
●   Written...
Rails Precepts
●   Convention over Configuration
    ●   Why punish the common cases?
    ●   Encourages standard practice...
Why Rails?
●   Greatly simplified web development
    ●   “Less Rails code than Java app configuration”
    ●   Instant ap...
The Rails Stack
●   ActiveRecord
    ●   ORM on steroids
●   ActionPack
    ●   View and controller support
●   ActiveReso...
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 se...
JRuby on Rails (Warbler)
●   Java-style deployment to Application Server
●   Bundles a Rails application into a WAR file
●...
JRuby on Rails (GlassFish v3 gem)
●   Entire App Server in a 4Mb gem
●   Ruby-style deployment to GF Application Server
  ...
Parts is Parts
●   Script Java technology you need into your Rails app
    ●   Call “legacy” Java from existing project
  ...
Swing GUI in JRuby
●   Builder approach (ex: Rubeus)
    ●   Sort of a “model 1” 1998 JSP approach
    ●   Great for simpl...
Upcoming SlideShare
Loading in...5
×

Devoxx%202008%20Tutorial

351

Published on

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

  • Be the first to like this

No Downloads
Views
Total Views
351
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Devoxx%202008%20Tutorial"

  1. 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. 2. The JRuby Guys ● Charles Oliver Nutter and Thomas Enebo ● JRuby for 4+ years ● Sun Microsystems for 2+ years ● JVM languages
  3. 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. 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. 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. 6. Modules Object MyGreatClass class MyGreatClass < Object … end
  7. 7. Modules Object MyGreatModule MyGreatClass class MyGreatClass < Object include MyGreatModule end
  8. 8. Modules Class class Object Object class meta class MyGreatClass MyGreatClass class meta class class MyGreatClass < Object extend MyGreatModule end
  9. 9. Modules Object Object Meta class MyGreatModule MyGreatClass MyGreatClass Meta class class MyGreatClass < Object extend MyGreatModule end
  10. 10. Singletons Object my_object MyGreatClass class MyGreatClass end my_object = MyGreatClass.new
  11. 11. Singletons Object MyGreatClass MyGreatClass my_object singleton class class MyGreatClass end my_object = MyGreatClass.new class << my_object end
  12. 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. 13. JVMScript (working title) ● A DSL for generating JVM bytecode ● Multiple Ruby techniques employed ● Goal: structured assembly for JVM
  14. 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. 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. 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. 17. The Rails Stack ● ActiveRecord ● ORM on steroids ● ActionPack ● View and controller support ● ActiveResource ● Restful resources ● Actionmailer ● Email ● Activesupport ● Unicode, json, miscellaneous helpers
  18. 18. Rails Demo Let's write a simple blog app
  19. 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. 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. 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. 22. Parts is Parts ● Script Java technology you need into your Rails app ● Call “legacy” Java from existing project ● Get additional choices
  23. 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
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×