SlideShare a Scribd company logo
1 of 31
Download to read offline
JRuby
Charles Oliver Nutter
JRuby Guy
Sun Microsystems
    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/).
                                                                                                                                  1
Agenda
• Ruby and JRuby overview
  > Facts and figures
  > Short Ruby tutorial
• Real-world JRuby
  > Graphics and games
  > Web applications
  > GUI programming
• Interactive: what do you want to know?




                                           2
The JRuby Guys
• Charles Oliver Nutter and Thomas Enebo
• Longtime Java developers (10+ yrs each)
• Engineers at Sun Microsystems for 2 years
• Full-time JRuby developers
• Also working on JVM dynlang support
• Wide range of past experience
  > C, C++, C#, Perl, Python, Delphi, Lisp, Scheme
  > Java EE and ME, JINI, WS




                                                     3
What Is Ruby
• Dynamic-typed, pure OO language
  > Interpreted
  > Open source, written in C
  > Good: easy to write, easy to read, powerful,
    “fun”
  > Bad: green threads, unicode support, libraries,
    “slow”
• Created 1993 by Yukihiro “Matz” Matsumoto
  > “More powerful than Perl and more OO than
    Python”
• Very active community, wide range of apps
• Ruby 1.8.x is current, 1.9 is in development

                                                      4
Ruby Growth (Gartner Projection)




                                   5
Ruby Conferences in 2008
RubyConf, RailsConf, RailsConf EU,
acts_as_conference, Euruko, Ruby Kaigi, Mountain
West RubyConf, eRubyCon, Ruby Hoedown,
Amsterdam Ruby en Rails, Scotland on Rails,
RubyFools Copenhagen, RubyFools Oslo, Voices that
Matter, South Carolina Ruby Conference, Lone Star
RubyConf, RuPy, Gotham Ruby Conference, Silicon
Valley Ruby Conference, RubyCamp, Conferencia
Rails, Rails Summit Latin America, Ruby Manor,
Atlanta Merb Day, ...




                                                    6
Ruby Books in 2008
NetBeans™ Ruby and Rails IDE with JRuby, Learning
Rails, Rails for .NET Developers, Wicked Cool Ruby
Scripts, JRuby Cookbook, Enterprise Recipes with Ruby
and Rails, Developing Facebook Platform Applications
with Rails, Foundation Rails 2, Enterprise Rails, Ruby On
Rails Bible, Rails: Up and Running, Rails Pocket
Reference, Ruby Phrasebook, Scripted GUI Testing with
Ruby, Aptana RadRails, Advanced Rails Recipes,
Deploying Rails Applications, The Art of Rails, Simply Rails
2, Practical REST on Rails 2 Projects, Ruby on Rails Web
Mashup Projects, FXRuby: Create Lean and Mean GUIs
with Ruby, RailsSpace, Ferret, Professional Ruby on Rails,
Ruby: The Programming Language, Rails for PHP
Developers, Pulling Strings with Puppet, Practical
Reporting with Ruby and Rails, The Ruby Programming
Language, Design Patterns in Ruby, Advanced Rails

                                                               7
JRuby
• Java implementation of Ruby language
   > “It's just Ruby!”
• Started in 2002, open source, many contributors
  > Ola Bini, Marcin Mielzynsky, Nick Sieger,
    Vladimir Sizikov, MenTaLguY, Wayne Meissner
• Aiming for compatibility with current Ruby version
  > Ruby 1.8.6
• Improvements on Ruby
   > Native threading, better performance, many
     libraries



                                                       8
Ruby Quick Tour: Pure OO
• Everything is an   Object
  > Circle.new(4)    => instance of Circle
  > “abc”.length     => 3
  > 1.to_s            => “1”
• All Objects are instances of Classes
  > 1.class      => Fixnum
• Single-Inheritance
• Object is base class of all classes




                                             9
Ruby Quick Tour: Basics
• Literals
  > Fixnum: 1
  > Float: 1.0
  > Bignum: 12345678987654321
  > String: “one” 'one' %Q[one] %q[one] ...
  > Multiline string (“here doc”):
        x = <<EOS
        extend across two
        lines
        EOS
  > Symbol: :one, %s[one]
  > Regexp: /^foow+.*bar$/, %r[^foo$]
  > Array: [1, “ein”, :ichi]
  > Hash: {:one => 1, :two => 2}
                                              10
Ruby Quick Tour: Basics
• String interpolation
  > a = “foo”
  > b = “bar#{a}baz” => “barfoobaz”
• Operator overloading
  > def +(arg); ...
• Attributes
  > class Foo
      attr_accessor :a
    end
    x = Foo.new
    x.a = “hello”
    puts x.a => “hello”


                                      11
Ruby Quick Tour: Duck Typing
• Dynamic typing
• “If it waddles like a duck and it quacks like a
  duck...”
     def make_it_waddle(waddler)
        waddler.waddle
     end

    make_it_waddle(Duck.new)   
    make_it_waddle(Penguin.new)
    make_it_waddle(Octopus.new)
• Runtime errors rarely happen
  > Unit testing helps prevent them

                                                    12
Ruby Quick Tour: A Simple Class
cl ass H l o
          el
   # i ni t i al i ze i s Ruby' s const r uct or
   def i ni t i al i ze( message)
     @ essage = m
       m                essage
   end

  def pr i nt
    # i nser t t he @ essage i nt o a st r i ng
                      m
    put s " Hel l o # m
                     {@ essage}"
  end
end

# const r uct a Hel l o obj ect
hel l o = H l o. new " Devoxx! " )
              el    (
hel l o. pr i nt


                                                   13
Ruby Quick Tour: Blocks/Closures
# t w f or m s: br aces {} and do . . end
     o       at
[ 1, 2, 3] . each {| num | put s “I see #
                        ber              {num }“ }
                                             ber
[ 1, 2, 3] . each do | num |
                           ber
   put s “I see # {num }“
                       ber
end

# m hods t hat accept bl ocks
   et
def f oo
  yi el d “hel l o“
end
def f oo2( &bl ock)
  bl ock. cal l ( “hel l o“)
end




                                                     14
Ruby Quick Tour: Modules
# A col l ect i on of obj ect s
cl ass M oduct s
          yPr
   # Enum abl e pr ovi des i t er at i on m hods
           er                              et
   i ncl ude Enum abl e
                  er

  # def i ne an ' each' m hod t hat i t er at es
                         et
  def each
    # yi el d each el ement i n t ur n
  end
end

l   i   st = M oduct s. new
                 yPr
l   i   st . sel ect {| i t em i t em pr i ce > 5. 00}
                              |      .
l   i   st . sor t {| a, b| a. nam < > b. nam
                                    e =          e}
l   i   st . max

                                                         15
Ruby Quick Tour: RubyGems
• Ruby's packaging system
  > Think CPAN, Maven, apt, rpm
• Shipped with JRuby
  > Step 1: unpack JRuby
  > Step 2 (optional): add 'bin' to PATH
  > Step 3: bin/gem install <whatever_you_desire>
  > You're ready to go!
• All major Ruby projects are in gems
  > Look for 'gem install ....' in upcoming slides




                                                     16
Where is JRuby being used?
• Graphics and Games
  > Ruby + graphics = cool
• JRuby on Rails
   > Better deployment options, better performance
• GUI development
  > Makes Swing much nicer to use, easier to
    handle




                                                     17
Ruby-Processing
• “Processing is an open source programming
  language and environment for people who want
  to program images, animation, and interactions.”
   > Basically a cool Java library for 2D graphics
• Ruby-Processing wraps Processing with JRuby
  > Cool, rubified 2D graphics environment for you
  > Eye-candy demos for us
  > Thanks to Jeremy Ashkenas for putting these
    together




                                                     18
JMonkeyEngine
• JMonkeyEngine: 3D Scenegraph library
   > OpenGL, Used Commercially




                                         19
DEMO
Pretty Graphics!




                   20
Web Applications: Ruby on Rails
• A Full-stack MVC web development framework
• Open Source (MIT), Many Contributors
• Written entirely in Ruby
• First released in 2004
• Growing popularity
  > RailsConf attendance: 500, 1000, 2500 since
    2006
  > Four Rails books downstairs (and more Ruby
    books)
  > Hundreds of job postings and growing fast



                                                  21
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
                                              22
The Rails Way: Controllers
# app/ cont r ol l er s/ per son_ cont r ol l er . r b

cl ass Per sonCont r ol l er < Appl i cat i onCont r ol l er
   ver i f y : m hod = : post ,
                et      >
             : onl y = [ : cr eat e, : updat e, : del et e]
                      >
                                                                 Rails
  def l i st                                                   Example
     @ l _ peopl e = Per son. f i nd : al l
       al
  end
  al i as : i ndex : l i st

  def updat e
    @ r y = Per son. f i nd( par am : i d] )
      ent                                s[
    @ r y. updat e_ at t r i but es( par am : per son] )
      ent                                     s[
    r edi r ect _ t o : act i on = ' l i st '
                                  >
  end
...


                                                                         23
The Rails Way: Views
< - - app/ vi ew per son/ l i st . r ht m - - >
 !              s/                       l

< abl e>
 t
   < r>
    t
   < f or col um i n Per son. cont ent _ col um %
    %           n                              ns >
      < h> % col um hum nam % < t h>
       t <=        n.    an_    e >/
   < end %
    %       >
   < tr>
    /                                                                             Rails
< f or per son i n @
 %                     peopl e %   >                                            Example
   < r>
    t
   < f or col um i n Per son. cont ent _ col um %
    %            n                                 ns >
      < d> % h per son. send( col um nam % < t d>
       t <=                             n.     e) > /
   < end %
    %       >
      < d> % l i nk_ t o ' Show , : act i on = ' show , : i d = per son % < t d>
       t <=                      '               >        '          >         >/
      < d> % l i nk_ t o ' Edi t ' , : act i on = ' edi t ' , : i d = per son % < t d>
       t <=                                      >                   >         >/
      < d> % l i nk_ t o ' D
       t <=                 est r oy' , { : act i on = ' dest r oy' , : i d = per son },
                                                      >                      >
                         : conf i r m = ' Ar e you sur e?' , : m hod = : post % < t d>
                                        >                           et     >         >/
   < tr>
    /
< end %
 %        >
< t abl e>
 /

< = l i nk_ t o ' Pr evi ous page' , { : page = @ son_ pages. cur r ent . pr evi ous } i f
 %                                             > per
                                                 @ son_pages. cur r ent . pr evi ous %
                                                  per                                  >
< = l i nk_ t o ' N
 %                 ext page' , { : page = @ son_ pages. cur r ent . next } i f
                                           > per
                                                 @ son_pages. cur r ent . next %
                                                  per                              >

                                                                                             24
The Rails Way: Persistence
# connect t o t he dat abase
Act i veRecor d: : Base. est abl i sh_connect i on(
        : adapt er = "m
                      >    ysql ", : dat abase = "m
                                                  >  ydb",
        : host     = "l ocal host ", : user nam = "m
                    >                            e >   ydb_user ",
        : passw d = "f oo" )
                or    >

# cr eat e a model obj ect
cl ass Cont act < Act i veRecor d: : Base
end

# per si st !
Cont act . cr eat e "nam = "Char l es N t er ",
                           e" >             ut
                    "t i t l e" = "J Ruby D
                                 >         evel oper "
Cont act . cr eat e "nam = "Thom Enebo", "t i t l e" = "J Ruby D
                           e" >        as              >        evel oper "

# quer y
Cont act . f i nd( : al l ) . each {| c| put s c. name}
nut t er = Cont act . f i nd_by_ nam "Char l es N t er ")
                                        e(            ut
                                                                       Rails
# updat e
nut t er . t i t l e = "D k O
                         ar  ver l ord of t he U ver se"
                                                ni
                                                                     Example
nut t er . save

                                                                               25
Rails Walkthrough




                    26
Production JRuby on Rails
• Sun's Kenai.com – project hosting site
  > www.kenai.com
• Oracle's Mix – digg-like social customer site
  > mix.oracle.com
• ThoughtWorks' Mingle – collaborative project
  mgmt
  > mingle.thoughtworks.com
• Trisano – infectious disease tracking for US gov'ts
  > www.trisano.org
• Many others in government, large biz, telecom


                                                        27
GUI Programming
• Swing API is very large, complex
  > Ruby magic simplifies most of the tricky bits
• Java is a very verbose language
   > Ruby makes Swing actually fun
• No consistent cross-platform GUI library for Ruby
  > Swing works everywhere Java does
    (everywhere)
• No fire-and-forget execution
  > No dependencies: any script works on any
    JRuby install



                                                      28
GUI Library Options
• Rubeus – gem install rubeus
  > Builder-like DSL syntax
• Profligacy – gem install profligacy
  > Rubified layout expression language
  > Trivial event binding without listeners
• MonkeyBars – gem install monkeybars
  > Leverage GUI builders
  > MVC structure
• ...and 5+ others for Swing, SWT, and Qt




                                              29
DEMO
Swing in Ruby




                30
Thank you!
• JRuby - www.jruby.org
   > wiki.jruby.org
• GlassFish - glassfish.dev.java.net
  > gem install glassfish
  > Looking for bug reports, feature requests!
• Charlie's blog: blog.headius.com
• Tom's blg:
  www.bloglines.com/blog/ThomasEEnebo




                                                 31

More Related Content

What's hot

The secret of programming language development and future
The secret of programming  language development and futureThe secret of programming  language development and future
The secret of programming language development and futureHiroshi SHIBATA
 
Gemification plan of Standard Library on Ruby
Gemification plan of Standard Library on RubyGemification plan of Standard Library on Ruby
Gemification plan of Standard Library on RubyHiroshi SHIBATA
 
Middleware as Code with mruby
Middleware as Code with mrubyMiddleware as Code with mruby
Middleware as Code with mrubyHiroshi SHIBATA
 
TorqueBox - Ultrapassando a fronteira entre Java e Ruby
TorqueBox - Ultrapassando a fronteira entre Java e RubyTorqueBox - Ultrapassando a fronteira entre Java e Ruby
TorqueBox - Ultrapassando a fronteira entre Java e RubyBruno Oliveira
 
Using Java from Ruby with JRuby IRB
Using Java from Ruby with JRuby IRBUsing Java from Ruby with JRuby IRB
Using Java from Ruby with JRuby IRBHiro Asari
 
A tour on ruby and friends
A tour on ruby and friendsA tour on ruby and friends
A tour on ruby and friends旻琦 潘
 
mruby で mackerel のプラグインを作るはなし
mruby で mackerel のプラグインを作るはなしmruby で mackerel のプラグインを作るはなし
mruby で mackerel のプラグインを作るはなしHiroshi SHIBATA
 
Introducing ruby on rails
Introducing ruby on railsIntroducing ruby on rails
Introducing ruby on railsPriceen
 
The Future of library dependency management of Ruby
 The Future of library dependency management of Ruby The Future of library dependency management of Ruby
The Future of library dependency management of RubyHiroshi SHIBATA
 
Security Goodness with Ruby on Rails
Security Goodness with Ruby on RailsSecurity Goodness with Ruby on Rails
Security Goodness with Ruby on RailsSource Conference
 
Ruby on Rails Presentation
Ruby on Rails PresentationRuby on Rails Presentation
Ruby on Rails Presentationadamcookeuk
 
How to Begin Developing Ruby Core
How to Begin Developing Ruby CoreHow to Begin Developing Ruby Core
How to Begin Developing Ruby CoreHiroshi SHIBATA
 
Rails for PHP Developers
Rails for PHP DevelopersRails for PHP Developers
Rails for PHP DevelopersRobert Dempsey
 
TorqueBox - When Java meets Ruby
TorqueBox - When Java meets RubyTorqueBox - When Java meets Ruby
TorqueBox - When Java meets RubyBruno Oliveira
 
Ruby - a tester's best friend
Ruby - a tester's best friendRuby - a tester's best friend
Ruby - a tester's best friendPeter Lind
 
Sinatra for REST services
Sinatra for REST servicesSinatra for REST services
Sinatra for REST servicesEmanuele DelBono
 
Gemification for Ruby 2.5/3.0
Gemification for Ruby 2.5/3.0Gemification for Ruby 2.5/3.0
Gemification for Ruby 2.5/3.0Hiroshi SHIBATA
 
Practical ngx_mruby
Practical ngx_mrubyPractical ngx_mruby
Practical ngx_mrubyHiroshi SHIBATA
 
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Course
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory CourseRuby on Rails 101 - Presentation Slides for a Five Day Introductory Course
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Coursepeter_marklund
 

What's hot (20)

The secret of programming language development and future
The secret of programming  language development and futureThe secret of programming  language development and future
The secret of programming language development and future
 
Gemification plan of Standard Library on Ruby
Gemification plan of Standard Library on RubyGemification plan of Standard Library on Ruby
Gemification plan of Standard Library on Ruby
 
Middleware as Code with mruby
Middleware as Code with mrubyMiddleware as Code with mruby
Middleware as Code with mruby
 
TorqueBox - Ultrapassando a fronteira entre Java e Ruby
TorqueBox - Ultrapassando a fronteira entre Java e RubyTorqueBox - Ultrapassando a fronteira entre Java e Ruby
TorqueBox - Ultrapassando a fronteira entre Java e Ruby
 
Using Java from Ruby with JRuby IRB
Using Java from Ruby with JRuby IRBUsing Java from Ruby with JRuby IRB
Using Java from Ruby with JRuby IRB
 
A tour on ruby and friends
A tour on ruby and friendsA tour on ruby and friends
A tour on ruby and friends
 
mruby で mackerel のプラグインを作るはなし
mruby で mackerel のプラグインを作るはなしmruby で mackerel のプラグインを作るはなし
mruby で mackerel のプラグインを作るはなし
 
Introducing ruby on rails
Introducing ruby on railsIntroducing ruby on rails
Introducing ruby on rails
 
The Future of library dependency management of Ruby
 The Future of library dependency management of Ruby The Future of library dependency management of Ruby
The Future of library dependency management of Ruby
 
Security Goodness with Ruby on Rails
Security Goodness with Ruby on RailsSecurity Goodness with Ruby on Rails
Security Goodness with Ruby on Rails
 
Ruby on Rails Presentation
Ruby on Rails PresentationRuby on Rails Presentation
Ruby on Rails Presentation
 
How to Begin Developing Ruby Core
How to Begin Developing Ruby CoreHow to Begin Developing Ruby Core
How to Begin Developing Ruby Core
 
What is nodejs
What is nodejsWhat is nodejs
What is nodejs
 
Rails for PHP Developers
Rails for PHP DevelopersRails for PHP Developers
Rails for PHP Developers
 
TorqueBox - When Java meets Ruby
TorqueBox - When Java meets RubyTorqueBox - When Java meets Ruby
TorqueBox - When Java meets Ruby
 
Ruby - a tester's best friend
Ruby - a tester's best friendRuby - a tester's best friend
Ruby - a tester's best friend
 
Sinatra for REST services
Sinatra for REST servicesSinatra for REST services
Sinatra for REST services
 
Gemification for Ruby 2.5/3.0
Gemification for Ruby 2.5/3.0Gemification for Ruby 2.5/3.0
Gemification for Ruby 2.5/3.0
 
Practical ngx_mruby
Practical ngx_mrubyPractical ngx_mruby
Practical ngx_mruby
 
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Course
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory CourseRuby on Rails 101 - Presentation Slides for a Five Day Introductory Course
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Course
 

Viewers also liked

Viewers also liked (7)

Intro
IntroIntro
Intro
 
Tutorial%20-%20Content%20Management%20System
Tutorial%20-%20Content%20Management%20SystemTutorial%20-%20Content%20Management%20System
Tutorial%20-%20Content%20Management%20System
 
dr_1
dr_1dr_1
dr_1
 
netbeans
netbeansnetbeans
netbeans
 
eureka09
eureka09eureka09
eureka09
 
User_Manual
User_ManualUser_Manual
User_Manual
 
toc
toctoc
toc
 

Similar to IJTC%202009%20JRuby

Why Ruby?
Why Ruby? Why Ruby?
Why Ruby? IT Weekend
 
How to Begin to Develop Ruby Core
How to Begin to Develop Ruby CoreHow to Begin to Develop Ruby Core
How to Begin to Develop Ruby CoreHiroshi SHIBATA
 
Exploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQLExploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQLBarry Jones
 
The story of language development
The story of language developmentThe story of language development
The story of language developmentHiroshi SHIBATA
 
Ruby on Rails : First Mile
Ruby on Rails : First MileRuby on Rails : First Mile
Ruby on Rails : First MileGourab Mitra
 
Introduction to Ruby
Introduction to RubyIntroduction to Ruby
Introduction to Rubykim.mens
 
Concurrecy in Ruby
Concurrecy in RubyConcurrecy in Ruby
Concurrecy in RubyVesna Doknic
 
JRuby - The Best of Java and Ruby
JRuby - The Best of Java and RubyJRuby - The Best of Java and Ruby
JRuby - The Best of Java and RubyEvgeny Rahman
 
Setup ruby
Setup rubySetup ruby
Setup rubyjugyo kohno
 
Ruby for C#-ers (ScanDevConf 2010)
Ruby for C#-ers (ScanDevConf 2010)Ruby for C#-ers (ScanDevConf 2010)
Ruby for C#-ers (ScanDevConf 2010)Thomas LundstrĂśm
 
JRuby - Enterprise 2.0
JRuby - Enterprise 2.0JRuby - Enterprise 2.0
JRuby - Enterprise 2.0Jan Sifra
 
How DSL works on Ruby
How DSL works on RubyHow DSL works on Ruby
How DSL works on RubyHiroshi SHIBATA
 
Ruby on Rails Presentation
Ruby on Rails PresentationRuby on Rails Presentation
Ruby on Rails PresentationMichael MacDonald
 
An introduction to the ruby ecosystem
An introduction to the ruby ecosystemAn introduction to the ruby ecosystem
An introduction to the ruby ecosystemGeison Goes
 
Why ruby
Why rubyWhy ruby
Why rubyBill Chea
 
Ruby Performance - The Last Mile - RubyConf India 2016
Ruby Performance - The Last Mile - RubyConf India 2016Ruby Performance - The Last Mile - RubyConf India 2016
Ruby Performance - The Last Mile - RubyConf India 2016Charles Nutter
 
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...Nilesh Panchal
 
Úvod do Ruby on Rails
Úvod do Ruby on RailsÚvod do Ruby on Rails
Úvod do Ruby on RailsKarel Minarik
 

Similar to IJTC%202009%20JRuby (20)

Why Ruby?
Why Ruby? Why Ruby?
Why Ruby?
 
How to Begin to Develop Ruby Core
How to Begin to Develop Ruby CoreHow to Begin to Develop Ruby Core
How to Begin to Develop Ruby Core
 
Exploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQLExploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQL
 
The story of language development
The story of language developmentThe story of language development
The story of language development
 
Children of Ruby
Children of RubyChildren of Ruby
Children of Ruby
 
Ruby on Rails : First Mile
Ruby on Rails : First MileRuby on Rails : First Mile
Ruby on Rails : First Mile
 
Bhavesh ro r
Bhavesh ro rBhavesh ro r
Bhavesh ro r
 
Introduction to Ruby
Introduction to RubyIntroduction to Ruby
Introduction to Ruby
 
Concurrecy in Ruby
Concurrecy in RubyConcurrecy in Ruby
Concurrecy in Ruby
 
JRuby - The Best of Java and Ruby
JRuby - The Best of Java and RubyJRuby - The Best of Java and Ruby
JRuby - The Best of Java and Ruby
 
Setup ruby
Setup rubySetup ruby
Setup ruby
 
Ruby for C#-ers (ScanDevConf 2010)
Ruby for C#-ers (ScanDevConf 2010)Ruby for C#-ers (ScanDevConf 2010)
Ruby for C#-ers (ScanDevConf 2010)
 
JRuby - Enterprise 2.0
JRuby - Enterprise 2.0JRuby - Enterprise 2.0
JRuby - Enterprise 2.0
 
How DSL works on Ruby
How DSL works on RubyHow DSL works on Ruby
How DSL works on Ruby
 
Ruby on Rails Presentation
Ruby on Rails PresentationRuby on Rails Presentation
Ruby on Rails Presentation
 
An introduction to the ruby ecosystem
An introduction to the ruby ecosystemAn introduction to the ruby ecosystem
An introduction to the ruby ecosystem
 
Why ruby
Why rubyWhy ruby
Why ruby
 
Ruby Performance - The Last Mile - RubyConf India 2016
Ruby Performance - The Last Mile - RubyConf India 2016Ruby Performance - The Last Mile - RubyConf India 2016
Ruby Performance - The Last Mile - RubyConf India 2016
 
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
 
Úvod do Ruby on Rails
Úvod do Ruby on RailsÚvod do Ruby on Rails
Úvod do Ruby on Rails
 

More from tutorialsruby

&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />tutorialsruby
 
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>TopStyle Help &amp; &lt;b>Tutorial&lt;/b>
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>tutorialsruby
 
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>tutorialsruby
 
&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />tutorialsruby
 
&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />tutorialsruby
 
Standardization and Knowledge Transfer – INS0
Standardization and Knowledge Transfer – INS0Standardization and Knowledge Transfer – INS0
Standardization and Knowledge Transfer – INS0tutorialsruby
 
xhtml-documentation
xhtml-documentationxhtml-documentation
xhtml-documentationtutorialsruby
 
xhtml-documentation
xhtml-documentationxhtml-documentation
xhtml-documentationtutorialsruby
 
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa0602690047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269tutorialsruby
 
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa0602690047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269tutorialsruby
 
BloggingWithStyle_2008
BloggingWithStyle_2008BloggingWithStyle_2008
BloggingWithStyle_2008tutorialsruby
 
BloggingWithStyle_2008
BloggingWithStyle_2008BloggingWithStyle_2008
BloggingWithStyle_2008tutorialsruby
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheetstutorialsruby
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheetstutorialsruby
 

More from tutorialsruby (20)

&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />
 
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>TopStyle Help &amp; &lt;b>Tutorial&lt;/b>
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>
 
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&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" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />
 
&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />
 
Standardization and Knowledge Transfer – INS0
Standardization and Knowledge Transfer – INS0Standardization and Knowledge Transfer – INS0
Standardization and Knowledge Transfer – INS0
 
xhtml_basics
xhtml_basicsxhtml_basics
xhtml_basics
 
xhtml_basics
xhtml_basicsxhtml_basics
xhtml_basics
 
xhtml-documentation
xhtml-documentationxhtml-documentation
xhtml-documentation
 
xhtml-documentation
xhtml-documentationxhtml-documentation
xhtml-documentation
 
CSS
CSSCSS
CSS
 
CSS
CSSCSS
CSS
 
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa0602690047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
 
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa0602690047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
 
HowTo_CSS
HowTo_CSSHowTo_CSS
HowTo_CSS
 
HowTo_CSS
HowTo_CSSHowTo_CSS
HowTo_CSS
 
BloggingWithStyle_2008
BloggingWithStyle_2008BloggingWithStyle_2008
BloggingWithStyle_2008
 
BloggingWithStyle_2008
BloggingWithStyle_2008BloggingWithStyle_2008
BloggingWithStyle_2008
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheets
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheets
 

Recently uploaded

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 

Recently uploaded (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 

IJTC%202009%20JRuby

  • 1. JRuby Charles Oliver Nutter JRuby Guy Sun Microsystems 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/). 1
  • 2. Agenda • Ruby and JRuby overview > Facts and figures > Short Ruby tutorial • Real-world JRuby > Graphics and games > Web applications > GUI programming • Interactive: what do you want to know? 2
  • 3. The JRuby Guys • Charles Oliver Nutter and Thomas Enebo • Longtime Java developers (10+ yrs each) • Engineers at Sun Microsystems for 2 years • Full-time JRuby developers • Also working on JVM dynlang support • Wide range of past experience > C, C++, C#, Perl, Python, Delphi, Lisp, Scheme > Java EE and ME, JINI, WS 3
  • 4. What Is Ruby • Dynamic-typed, pure OO language > Interpreted > Open source, written in C > Good: easy to write, easy to read, powerful, “fun” > Bad: green threads, unicode support, libraries, “slow” • Created 1993 by Yukihiro “Matz” Matsumoto > “More powerful than Perl and more OO than Python” • Very active community, wide range of apps • Ruby 1.8.x is current, 1.9 is in development 4
  • 5. Ruby Growth (Gartner Projection) 5
  • 6. Ruby Conferences in 2008 RubyConf, RailsConf, RailsConf EU, acts_as_conference, Euruko, Ruby Kaigi, Mountain West RubyConf, eRubyCon, Ruby Hoedown, Amsterdam Ruby en Rails, Scotland on Rails, RubyFools Copenhagen, RubyFools Oslo, Voices that Matter, South Carolina Ruby Conference, Lone Star RubyConf, RuPy, Gotham Ruby Conference, Silicon Valley Ruby Conference, RubyCamp, Conferencia Rails, Rails Summit Latin America, Ruby Manor, Atlanta Merb Day, ... 6
  • 7. Ruby Books in 2008 NetBeans™ Ruby and Rails IDE with JRuby, Learning Rails, Rails for .NET Developers, Wicked Cool Ruby Scripts, JRuby Cookbook, Enterprise Recipes with Ruby and Rails, Developing Facebook Platform Applications with Rails, Foundation Rails 2, Enterprise Rails, Ruby On Rails Bible, Rails: Up and Running, Rails Pocket Reference, Ruby Phrasebook, Scripted GUI Testing with Ruby, Aptana RadRails, Advanced Rails Recipes, Deploying Rails Applications, The Art of Rails, Simply Rails 2, Practical REST on Rails 2 Projects, Ruby on Rails Web Mashup Projects, FXRuby: Create Lean and Mean GUIs with Ruby, RailsSpace, Ferret, Professional Ruby on Rails, Ruby: The Programming Language, Rails for PHP Developers, Pulling Strings with Puppet, Practical Reporting with Ruby and Rails, The Ruby Programming Language, Design Patterns in Ruby, Advanced Rails 7
  • 8. JRuby • Java implementation of Ruby language > “It's just Ruby!” • Started in 2002, open source, many contributors > Ola Bini, Marcin Mielzynsky, Nick Sieger, Vladimir Sizikov, MenTaLguY, Wayne Meissner • Aiming for compatibility with current Ruby version > Ruby 1.8.6 • Improvements on Ruby > Native threading, better performance, many libraries 8
  • 9. Ruby Quick Tour: Pure OO • Everything is an Object > Circle.new(4) => instance of Circle > “abc”.length => 3 > 1.to_s => “1” • All Objects are instances of Classes > 1.class => Fixnum • Single-Inheritance • Object is base class of all classes 9
  • 10. Ruby Quick Tour: Basics • Literals > Fixnum: 1 > Float: 1.0 > Bignum: 12345678987654321 > String: “one” 'one' %Q[one] %q[one] ... > Multiline string (“here doc”): x = <<EOS extend across two lines EOS > Symbol: :one, %s[one] > Regexp: /^foow+.*bar$/, %r[^foo$] > Array: [1, “ein”, :ichi] > Hash: {:one => 1, :two => 2} 10
  • 11. Ruby Quick Tour: Basics • String interpolation > a = “foo” > b = “bar#{a}baz” => “barfoobaz” • Operator overloading > def +(arg); ... • Attributes > class Foo attr_accessor :a end x = Foo.new x.a = “hello” puts x.a => “hello” 11
  • 12. Ruby Quick Tour: Duck Typing • Dynamic typing • “If it waddles like a duck and it quacks like a duck...” def make_it_waddle(waddler)    waddler.waddle end make_it_waddle(Duck.new)    make_it_waddle(Penguin.new) make_it_waddle(Octopus.new) • Runtime errors rarely happen > Unit testing helps prevent them 12
  • 13. Ruby Quick Tour: A Simple Class cl ass H l o el # i ni t i al i ze i s Ruby' s const r uct or def i ni t i al i ze( message) @ essage = m m essage end def pr i nt # i nser t t he @ essage i nt o a st r i ng m put s " Hel l o # m {@ essage}" end end # const r uct a Hel l o obj ect hel l o = H l o. new " Devoxx! " ) el ( hel l o. pr i nt 13
  • 14. Ruby Quick Tour: Blocks/Closures # t w f or m s: br aces {} and do . . end o at [ 1, 2, 3] . each {| num | put s “I see # ber {num }“ } ber [ 1, 2, 3] . each do | num | ber put s “I see # {num }“ ber end # m hods t hat accept bl ocks et def f oo yi el d “hel l o“ end def f oo2( &bl ock) bl ock. cal l ( “hel l o“) end 14
  • 15. Ruby Quick Tour: Modules # A col l ect i on of obj ect s cl ass M oduct s yPr # Enum abl e pr ovi des i t er at i on m hods er et i ncl ude Enum abl e er # def i ne an ' each' m hod t hat i t er at es et def each # yi el d each el ement i n t ur n end end l i st = M oduct s. new yPr l i st . sel ect {| i t em i t em pr i ce > 5. 00} | . l i st . sor t {| a, b| a. nam < > b. nam e = e} l i st . max 15
  • 16. Ruby Quick Tour: RubyGems • Ruby's packaging system > Think CPAN, Maven, apt, rpm • Shipped with JRuby > Step 1: unpack JRuby > Step 2 (optional): add 'bin' to PATH > Step 3: bin/gem install <whatever_you_desire> > You're ready to go! • All major Ruby projects are in gems > Look for 'gem install ....' in upcoming slides 16
  • 17. Where is JRuby being used? • Graphics and Games > Ruby + graphics = cool • JRuby on Rails > Better deployment options, better performance • GUI development > Makes Swing much nicer to use, easier to handle 17
  • 18. Ruby-Processing • “Processing is an open source programming language and environment for people who want to program images, animation, and interactions.” > Basically a cool Java library for 2D graphics • Ruby-Processing wraps Processing with JRuby > Cool, rubified 2D graphics environment for you > Eye-candy demos for us > Thanks to Jeremy Ashkenas for putting these together 18
  • 19. JMonkeyEngine • JMonkeyEngine: 3D Scenegraph library > OpenGL, Used Commercially 19
  • 21. Web Applications: Ruby on Rails • A Full-stack MVC web development framework • Open Source (MIT), Many Contributors • Written entirely in Ruby • First released in 2004 • Growing popularity > RailsConf attendance: 500, 1000, 2500 since 2006 > Four Rails books downstairs (and more Ruby books) > Hundreds of job postings and growing fast 21
  • 22. 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 22
  • 23. The Rails Way: Controllers # app/ cont r ol l er s/ per son_ cont r ol l er . r b cl ass Per sonCont r ol l er < Appl i cat i onCont r ol l er ver i f y : m hod = : post , et > : onl y = [ : cr eat e, : updat e, : del et e] > Rails def l i st Example @ l _ peopl e = Per son. f i nd : al l al end al i as : i ndex : l i st def updat e @ r y = Per son. f i nd( par am : i d] ) ent s[ @ r y. updat e_ at t r i but es( par am : per son] ) ent s[ r edi r ect _ t o : act i on = ' l i st ' > end ... 23
  • 24. The Rails Way: Views < - - app/ vi ew per son/ l i st . r ht m - - > ! s/ l < abl e> t < r> t < f or col um i n Per son. cont ent _ col um % % n ns > < h> % col um hum nam % < t h> t <= n. an_ e >/ < end % % > < tr> / Rails < f or per son i n @ % peopl e % > Example < r> t < f or col um i n Per son. cont ent _ col um % % n ns > < d> % h per son. send( col um nam % < t d> t <= n. e) > / < end % % > < d> % l i nk_ t o ' Show , : act i on = ' show , : i d = per son % < t d> t <= ' > ' > >/ < d> % l i nk_ t o ' Edi t ' , : act i on = ' edi t ' , : i d = per son % < t d> t <= > > >/ < d> % l i nk_ t o ' D t <= est r oy' , { : act i on = ' dest r oy' , : i d = per son }, > > : conf i r m = ' Ar e you sur e?' , : m hod = : post % < t d> > et > >/ < tr> / < end % % > < t abl e> / < = l i nk_ t o ' Pr evi ous page' , { : page = @ son_ pages. cur r ent . pr evi ous } i f % > per @ son_pages. cur r ent . pr evi ous % per > < = l i nk_ t o ' N % ext page' , { : page = @ son_ pages. cur r ent . next } i f > per @ son_pages. cur r ent . next % per > 24
  • 25. The Rails Way: Persistence # connect t o t he dat abase Act i veRecor d: : Base. est abl i sh_connect i on( : adapt er = "m > ysql ", : dat abase = "m > ydb", : host = "l ocal host ", : user nam = "m > e > ydb_user ", : passw d = "f oo" ) or > # cr eat e a model obj ect cl ass Cont act < Act i veRecor d: : Base end # per si st ! Cont act . cr eat e "nam = "Char l es N t er ", e" > ut "t i t l e" = "J Ruby D > evel oper " Cont act . cr eat e "nam = "Thom Enebo", "t i t l e" = "J Ruby D e" > as > evel oper " # quer y Cont act . f i nd( : al l ) . each {| c| put s c. name} nut t er = Cont act . f i nd_by_ nam "Char l es N t er ") e( ut Rails # updat e nut t er . t i t l e = "D k O ar ver l ord of t he U ver se" ni Example nut t er . save 25
  • 27. Production JRuby on Rails • Sun's Kenai.com – project hosting site > www.kenai.com • Oracle's Mix – digg-like social customer site > mix.oracle.com • ThoughtWorks' Mingle – collaborative project mgmt > mingle.thoughtworks.com • Trisano – infectious disease tracking for US gov'ts > www.trisano.org • Many others in government, large biz, telecom 27
  • 28. GUI Programming • Swing API is very large, complex > Ruby magic simplifies most of the tricky bits • Java is a very verbose language > Ruby makes Swing actually fun • No consistent cross-platform GUI library for Ruby > Swing works everywhere Java does (everywhere) • No fire-and-forget execution > No dependencies: any script works on any JRuby install 28
  • 29. GUI Library Options • Rubeus – gem install rubeus > Builder-like DSL syntax • Profligacy – gem install profligacy > Rubified layout expression language > Trivial event binding without listeners • MonkeyBars – gem install monkeybars > Leverage GUI builders > MVC structure • ...and 5+ others for Swing, SWT, and Qt 29
  • 31. Thank you! • JRuby - www.jruby.org > wiki.jruby.org • GlassFish - glassfish.dev.java.net > gem install glassfish > Looking for bug reports, feature requests! • Charlie's blog: blog.headius.com • Tom's blg: www.bloglines.com/blog/ThomasEEnebo 31