SlideShare a Scribd company logo
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

7 Common mistakes in Go and when to avoid them
7 Common mistakes in Go and when to avoid them7 Common mistakes in Go and when to avoid them
7 Common mistakes in Go and when to avoid them
Steven Francia
 
7 Common Mistakes in Go (2015)
7 Common Mistakes in Go (2015)7 Common Mistakes in Go (2015)
7 Common Mistakes in Go (2015)
Steven Francia
 
Unleash your inner console cowboy
Unleash your inner console cowboyUnleash your inner console cowboy
Unleash your inner console cowboy
Kenneth Geisshirt
 
Painless Data Storage with MongoDB & Go
Painless Data Storage with MongoDB & Go Painless Data Storage with MongoDB & Go
Painless Data Storage with MongoDB & Go
Steven Francia
 
Unix Shell Scripting Basics
Unix Shell Scripting BasicsUnix Shell Scripting Basics
Unix Shell Scripting BasicsSudharsan S
 
Linux administration training
Linux administration trainingLinux administration training
Linux administration training
iman darabi
 
Getting Started with Go
Getting Started with GoGetting Started with Go
Getting Started with Go
Steven Francia
 
What to do when things go wrong
What to do when things go wrongWhat to do when things go wrong
What to do when things go wrong
Dorneles Treméa
 
Network programming
Network programmingNetwork programming
OSCON2014 : Quick Introduction to System Tools Programming with Go
OSCON2014 : Quick Introduction to System Tools Programming with GoOSCON2014 : Quick Introduction to System Tools Programming with Go
OSCON2014 : Quick Introduction to System Tools Programming with Go
Chris McEniry
 
Happy Go Programming
Happy Go ProgrammingHappy Go Programming
Happy Go Programming
Lin Yo-An
 
Linux fundamental - Chap 14 shell script
Linux fundamental - Chap 14 shell scriptLinux fundamental - Chap 14 shell script
Linux fundamental - Chap 14 shell script
Kenny (netman)
 
Beautiful Bash: Let's make reading and writing bash scripts fun again!
Beautiful Bash: Let's make reading and writing bash scripts fun again!Beautiful Bash: Let's make reading and writing bash scripts fun again!
Beautiful Bash: Let's make reading and writing bash scripts fun again!
Aaron Zauner
 
Go for SysAdmins - LISA 2015
Go for SysAdmins - LISA 2015Go for SysAdmins - LISA 2015
Go for SysAdmins - LISA 2015
Chris McEniry
 
On the Edge Systems Administration with Golang
On the Edge Systems Administration with GolangOn the Edge Systems Administration with Golang
On the Edge Systems Administration with Golang
Chris McEniry
 
Lecture 3 Perl & FreeBSD administration
Lecture 3 Perl & FreeBSD administrationLecture 3 Perl & FreeBSD administration
Lecture 3 Perl & FreeBSD administrationMohammed Farrag
 
Go for Object Oriented Programmers or Object Oriented Programming without Obj...
Go for Object Oriented Programmers or Object Oriented Programming without Obj...Go for Object Oriented Programmers or Object Oriented Programming without Obj...
Go for Object Oriented Programmers or Object Oriented Programming without Obj...
Steven Francia
 
HipHop Virtual Machine
HipHop Virtual MachineHipHop Virtual Machine
HipHop Virtual Machine
Radu Murzea
 
JavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for DummiesJavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for DummiesCharles Nutter
 

What's hot (20)

7 Common mistakes in Go and when to avoid them
7 Common mistakes in Go and when to avoid them7 Common mistakes in Go and when to avoid them
7 Common mistakes in Go and when to avoid them
 
7 Common Mistakes in Go (2015)
7 Common Mistakes in Go (2015)7 Common Mistakes in Go (2015)
7 Common Mistakes in Go (2015)
 
iSoligorsk #3 2013
iSoligorsk #3 2013iSoligorsk #3 2013
iSoligorsk #3 2013
 
Unleash your inner console cowboy
Unleash your inner console cowboyUnleash your inner console cowboy
Unleash your inner console cowboy
 
Painless Data Storage with MongoDB & Go
Painless Data Storage with MongoDB & Go Painless Data Storage with MongoDB & Go
Painless Data Storage with MongoDB & Go
 
Unix Shell Scripting Basics
Unix Shell Scripting BasicsUnix Shell Scripting Basics
Unix Shell Scripting Basics
 
Linux administration training
Linux administration trainingLinux administration training
Linux administration training
 
Getting Started with Go
Getting Started with GoGetting Started with Go
Getting Started with Go
 
What to do when things go wrong
What to do when things go wrongWhat to do when things go wrong
What to do when things go wrong
 
Network programming
Network programmingNetwork programming
Network programming
 
OSCON2014 : Quick Introduction to System Tools Programming with Go
OSCON2014 : Quick Introduction to System Tools Programming with GoOSCON2014 : Quick Introduction to System Tools Programming with Go
OSCON2014 : Quick Introduction to System Tools Programming with Go
 
Happy Go Programming
Happy Go ProgrammingHappy Go Programming
Happy Go Programming
 
Linux fundamental - Chap 14 shell script
Linux fundamental - Chap 14 shell scriptLinux fundamental - Chap 14 shell script
Linux fundamental - Chap 14 shell script
 
Beautiful Bash: Let's make reading and writing bash scripts fun again!
Beautiful Bash: Let's make reading and writing bash scripts fun again!Beautiful Bash: Let's make reading and writing bash scripts fun again!
Beautiful Bash: Let's make reading and writing bash scripts fun again!
 
Go for SysAdmins - LISA 2015
Go for SysAdmins - LISA 2015Go for SysAdmins - LISA 2015
Go for SysAdmins - LISA 2015
 
On the Edge Systems Administration with Golang
On the Edge Systems Administration with GolangOn the Edge Systems Administration with Golang
On the Edge Systems Administration with Golang
 
Lecture 3 Perl & FreeBSD administration
Lecture 3 Perl & FreeBSD administrationLecture 3 Perl & FreeBSD administration
Lecture 3 Perl & FreeBSD administration
 
Go for Object Oriented Programmers or Object Oriented Programming without Obj...
Go for Object Oriented Programmers or Object Oriented Programming without Obj...Go for Object Oriented Programmers or Object Oriented Programming without Obj...
Go for Object Oriented Programmers or Object Oriented Programming without Obj...
 
HipHop Virtual Machine
HipHop Virtual MachineHipHop Virtual Machine
HipHop Virtual Machine
 
JavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for DummiesJavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for Dummies
 

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 Core
Hiroshi SHIBATA
 
Exploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQLExploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQL
Barry Jones
 
The story of language development
The story of language developmentThe story of language development
The story of language development
Hiroshi SHIBATA
 
Children of Ruby
Children of RubyChildren of Ruby
Children of Ruby
Simon St.Laurent
 
Ruby on Rails : First Mile
Ruby on Rails : First MileRuby on Rails : First Mile
Ruby on Rails : First Mile
Gourab Mitra
 
Bhavesh ro r
Bhavesh ro rBhavesh ro r
Bhavesh ro r
bhavesh-gloscon
 
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
Hiroshi SHIBATA
 
Introduction to Ruby
Introduction to RubyIntroduction to Ruby
Introduction to Ruby
kim.mens
 
Concurrecy in Ruby
Concurrecy in RubyConcurrecy in Ruby
Concurrecy in Ruby
Vesna 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
 
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 Ruby
Hiroshi SHIBATA
 
Ruby on Rails Presentation
Ruby on Rails PresentationRuby on Rails Presentation
Ruby on Rails Presentation
Michael MacDonald
 
An introduction to the ruby ecosystem
An introduction to the ruby ecosystemAn introduction to the ruby ecosystem
An introduction to the ruby ecosystem
Geison Goes
 
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
Charles 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
 

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
 
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
 
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...
 

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
 
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

ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
CatarinaPereira64715
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
Fwdays
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
Abida Shariff
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 

Recently uploaded (20)

ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 

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