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

PDF
Connecting the Worlds of Java and Ruby with JRuby
Nick Sieger
 
PDF
Hijacking Ruby Syntax in Ruby
SATOSHI TAGOMORI
 
PDF
The Enterprise Strikes Back
Burke Libbey
 
PDF
Middleware as Code with mruby
Hiroshi SHIBATA
 
PDF
Large-scaled Deploy Over 100 Servers in 3 Minutes
Hiroshi SHIBATA
 
PDF
RubyGems 3 & 4
Hiroshi SHIBATA
 
PDF
TRICK2015 results
mametter
 
PPTX
JRuby in Java Projects
jazzman1980
 
Connecting the Worlds of Java and Ruby with JRuby
Nick Sieger
 
Hijacking Ruby Syntax in Ruby
SATOSHI TAGOMORI
 
The Enterprise Strikes Back
Burke Libbey
 
Middleware as Code with mruby
Hiroshi SHIBATA
 
Large-scaled Deploy Over 100 Servers in 3 Minutes
Hiroshi SHIBATA
 
RubyGems 3 & 4
Hiroshi SHIBATA
 
TRICK2015 results
mametter
 
JRuby in Java Projects
jazzman1980
 

What's hot (20)

PDF
The secret of programming language development and future
Hiroshi SHIBATA
 
PDF
Gemification plan of Standard Library on Ruby
Hiroshi SHIBATA
 
PDF
Middleware as Code with mruby
Hiroshi SHIBATA
 
PDF
TorqueBox - Ultrapassando a fronteira entre Java e Ruby
Bruno Oliveira
 
PDF
Using Java from Ruby with JRuby IRB
Hiro Asari
 
KEY
A tour on ruby and friends
旻琦 潘
 
PDF
mruby で mackerel のプラグインを作るはなし
Hiroshi SHIBATA
 
PDF
Introducing ruby on rails
Priceen
 
PDF
The Future of library dependency management of Ruby
Hiroshi SHIBATA
 
PDF
Security Goodness with Ruby on Rails
Source Conference
 
PDF
Ruby on Rails Presentation
adamcookeuk
 
PDF
How to Begin Developing Ruby Core
Hiroshi SHIBATA
 
PDF
What is nodejs
JeongHun Byeon
 
KEY
Rails for PHP Developers
Robert Dempsey
 
PDF
TorqueBox - When Java meets Ruby
Bruno Oliveira
 
PDF
Ruby - a tester's best friend
Peter Lind
 
KEY
Sinatra for REST services
Emanuele DelBono
 
PDF
Gemification for Ruby 2.5/3.0
Hiroshi SHIBATA
 
PDF
Practical ngx_mruby
Hiroshi SHIBATA
 
PDF
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Course
peter_marklund
 
The secret of programming language development and future
Hiroshi SHIBATA
 
Gemification plan of Standard Library on Ruby
Hiroshi SHIBATA
 
Middleware as Code with mruby
Hiroshi SHIBATA
 
TorqueBox - Ultrapassando a fronteira entre Java e Ruby
Bruno Oliveira
 
Using Java from Ruby with JRuby IRB
Hiro Asari
 
A tour on ruby and friends
旻琦 潘
 
mruby で mackerel のプラグインを作るはなし
Hiroshi SHIBATA
 
Introducing ruby on rails
Priceen
 
The Future of library dependency management of Ruby
Hiroshi SHIBATA
 
Security Goodness with Ruby on Rails
Source Conference
 
Ruby on Rails Presentation
adamcookeuk
 
How to Begin Developing Ruby Core
Hiroshi SHIBATA
 
What is nodejs
JeongHun Byeon
 
Rails for PHP Developers
Robert Dempsey
 
TorqueBox - When Java meets Ruby
Bruno Oliveira
 
Ruby - a tester's best friend
Peter Lind
 
Sinatra for REST services
Emanuele DelBono
 
Gemification for Ruby 2.5/3.0
Hiroshi SHIBATA
 
Practical ngx_mruby
Hiroshi SHIBATA
 
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Course
peter_marklund
 
Ad

Viewers also liked (7)

PDF
Intro
tutorialsruby
 
PDF
Tutorial%20-%20Content%20Management%20System
tutorialsruby
 
PDF
dr_1
tutorialsruby
 
PDF
netbeans
tutorialsruby
 
PDF
eureka09
tutorialsruby
 
PDF
User_Manual
tutorialsruby
 
Tutorial%20-%20Content%20Management%20System
tutorialsruby
 
netbeans
tutorialsruby
 
eureka09
tutorialsruby
 
User_Manual
tutorialsruby
 
Ad

Similar to IJTC%202009%20JRuby (20)

PDF
Ruby an overall approach
Felipe Schmitt
 
PPT
Rapid Application Development using Ruby on Rails
Simobo
 
KEY
Ruby on Rails Training - Module 1
Mark Menard
 
PPTX
Why Ruby?
IT Weekend
 
ZIP
Meta Programming in Ruby - Code Camp 2010
ssoroka
 
PDF
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
Nilesh Panchal
 
KEY
Introducing Ruby
James Thompson
 
PDF
Ruby on Rails
bryanbibat
 
KEY
Introduction to Ruby
Mark Menard
 
PDF
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
Nick Sieger
 
PDF
Ruby Presentation
platico_dev
 
PPT
Workin ontherailsroad
Jim Jones
 
PPT
WorkinOnTheRailsRoad
webuploader
 
PDF
Ruby On Rails pizza training
david_alphen
 
PPTX
Adventures of java developer in ruby world
Orest Ivasiv
 
PPTX
Ruby for .NET developers
Max Titov
 
PPT
Intro for RoR
Vigneshwaran Seetharaman
 
KEY
Intro to Ruby on Rails
rschmukler
 
PPTX
Why ruby
Bill Chea
 
PDF
遇見 Ruby on Rails
Wen-Tien Chang
 
Ruby an overall approach
Felipe Schmitt
 
Rapid Application Development using Ruby on Rails
Simobo
 
Ruby on Rails Training - Module 1
Mark Menard
 
Why Ruby?
IT Weekend
 
Meta Programming in Ruby - Code Camp 2010
ssoroka
 
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
Nilesh Panchal
 
Introducing Ruby
James Thompson
 
Ruby on Rails
bryanbibat
 
Introduction to Ruby
Mark Menard
 
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
Nick Sieger
 
Ruby Presentation
platico_dev
 
Workin ontherailsroad
Jim Jones
 
WorkinOnTheRailsRoad
webuploader
 
Ruby On Rails pizza training
david_alphen
 
Adventures of java developer in ruby world
Orest Ivasiv
 
Ruby for .NET developers
Max Titov
 
Intro to Ruby on Rails
rschmukler
 
Why ruby
Bill Chea
 
遇見 Ruby on Rails
Wen-Tien Chang
 

More from tutorialsruby (20)

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

Recently uploaded (20)

PDF
How ETL Control Logic Keeps Your Pipelines Safe and Reliable.pdf
Stryv Solutions Pvt. Ltd.
 
PDF
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
PDF
Peak of Data & AI Encore - Real-Time Insights & Scalable Editing with ArcGIS
Safe Software
 
PDF
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
PDF
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
PDF
Get More from Fiori Automation - What’s New, What Works, and What’s Next.pdf
Precisely
 
PDF
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 
PDF
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
PPTX
The Future of AI & Machine Learning.pptx
pritsen4700
 
PPTX
AI in Daily Life: How Artificial Intelligence Helps Us Every Day
vanshrpatil7
 
PPTX
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PDF
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
PDF
A Strategic Analysis of the MVNO Wave in Emerging Markets.pdf
IPLOOK Networks
 
PDF
GDG Cloud Munich - Intro - Luiz Carneiro - #BuildWithAI - July - Abdel.pdf
Luiz Carneiro
 
PDF
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
PDF
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
 
PDF
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
PDF
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
 
PDF
The Future of Artificial Intelligence (AI)
Mukul
 
How ETL Control Logic Keeps Your Pipelines Safe and Reliable.pdf
Stryv Solutions Pvt. Ltd.
 
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
Peak of Data & AI Encore - Real-Time Insights & Scalable Editing with ArcGIS
Safe Software
 
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
Get More from Fiori Automation - What’s New, What Works, and What’s Next.pdf
Precisely
 
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
The Future of AI & Machine Learning.pptx
pritsen4700
 
AI in Daily Life: How Artificial Intelligence Helps Us Every Day
vanshrpatil7
 
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
A Strategic Analysis of the MVNO Wave in Emerging Markets.pdf
IPLOOK Networks
 
GDG Cloud Munich - Intro - Luiz Carneiro - #BuildWithAI - July - Abdel.pdf
Luiz Carneiro
 
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
 
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
 
The Future of Artificial Intelligence (AI)
Mukul
 

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