SlideShare ist ein Scribd-Unternehmen logo
1 von 62
Downloaden Sie, um offline zu lesen
Nick Sieger
@nicksieger
(RE-)
INTRO
Ruby on
the JVM
Best of Ruby
 and Java...
 Together!
http://www.flickr.com/photos/texascooking/5864122096/
COMPAT
IBILITY
runs nearly all pure ruby code

runs 92% of rubyspec suite

runs ~30% of 1.9 test suite

(even more with 1.8 mode)
http://jruby.org/download

    rvm install jruby

   INSTALL   gem install jruby-lint




             $ jrlint
drawbacks
startup time

memory footprint

native code

no Kernel#fork
PERFOR
MANCE
GC.pauses =
 “no thanks”
class Simple
  attr_accessor :next
end

top = Simple.new

puts Benchmark.measure {
  outer = 10
  total = 100000
  per = 100

  outer.times do
    total.times do
      per.times { Simple.new }
      s = Simple.new
      top.next = s
      top = s
    end
  end
}
Ruby 1.9.3              JRuby
8000


6000


4000


2000


  0
                    GC count
Ruby 1.9.3              JRuby
10000


 1000


  100


   10


    1
                     GC count
15
     Ruby 1.9.3               JRuby

12


9


6


3


0
                  GC time %
Time per GC versus heap usage

300ms

              Ruby 2.0.0                JRuby
225ms


150ms


75ms


 0ms
 188KB/29MB                27MB/127MB           199MB/238MB

                 Heap usage (MRI/JRuby)
REAL
THREADS
Ruby 1.9     Ruby 1.9
unthreaded   threaded




  JRuby        JRuby
unthreaded   threaded
sidekiq.org
 What if 1 Sidekiq process could
 do the work of 20 Resque or
 DelayedJob processes?
COMPILER
Ruby application code

     JVM bytecode           Key

        Native code




                          Ruby             Ruby
     Ruby code
                          code             code
                                  Ruby             Ruby
        JRuby             JRuby            JRuby
                                  code             code
                                                           Ruby
         JVM              JVM     JRuby    JVM     JRuby
                                                           code


Full interpretation      JRuby compiler   HotSpot compiler

 Time
BENCH
MARKS
Red-Black Tree
5


4
          ruby 1.9.3p286
          jruby 1.7.0 java 1.6.0_29
3
          jruby 1.7.0 java 1.7.0_09
          jruby 1.7.0 java 1.7.0_09-b05 +indy
2


1


0
Times Faster than Ruby 1.9.3
  5
           JRuby/Java 6                   JRuby/Java 7+indy
                                                     4.226           4.32
3.75
                                          3.66
                           3.44
 2.5       2.658

                                  1.914          1.806
1.25               1.538                                     1.565
       1.346


  0
        base64     richards        neural mandelbrot redblack
Java 7
Get JDK 7
   (OSX too!)
java.oracle.com
INVOKE
DYNAMIC
experthuman.com/
programming-with-
      nothing
    Tom Stuart
    @tomstuart
# lambda
-> x {
}
# call
p[x]
FIZZ
BUZZ
(1..100).each do |n|
  if (n % 15).zero?
    puts 'FizzBuzz'
  elsif (n % 3).zero?
    puts 'Fizz'
  elsif (n % 5).zero?
    puts 'Buzz'
  else
    puts n.to_s
  end
end
fizzbuzz = -> k { -> f { -> f { -> x { f[-> y { x[x][y] }] }[-> x {
f[-> y { x[x][y] }] }] }[-> f { -> l { -> x { -> g { -> b { b }[-> p {
p[-> x { -> y { x } } ] }[l]][x][-> y { g[f[-> l { -> p { p[-> x { ->
y { y } } ] }[-> p { p[-> x { -> y { y } } ] }[l]] }[l]][x][g]][-> l {
-> p { p[-> x { -> y { x } } ] }[-> p { p[-> x { -> y { y } } ] }[l]]
}[l]][y] }] } } } }][k][-> x { -> y { -> f { f[x][y] } } }[-> x { -> y
{ x } }][-> x { -> y { x } }]][-> l { -> x { -> l { -> x { -> x { -> y
{ -> f { f[x][y] } } }[-> x { -> y { y } }][-> x { -> y { -> f {
f[x][y] } } }[x][l]] } }[l][f[x]] } }] } }[-> f { -> x { f[-> y {
x[x][y] }] }[-> x { f[-> y { x[x][y] }] }] }[-> f { -> m { -> n { -> b
{ b }[-> m { -> n { -> n { n[-> x { -> x { -> y { y } } }][-> x { -> y
{ x } }] }[-> m { -> n { n[-> n { -> f { -> x { n[-> g { -> h {
h[g[f]] } }][-> y { x }][-> y { y }] } } }][m] } }[m][n]] }
}[m][n]][-> x { -> l { -> x { -> x { -> y { -> f { f[x][y] } } }[-> x
{ -> y { y } }][-> x { -> y { -> f { f[x][y] } } }[x][l]] } }[f[-> n {
-> p { -> x { p[n[p][x]] } } }[m]][n]][m][x] }][-> x { -> y { -> f {
f[x][y] } } }[-> x { -> y { x } }][-> x { -> y { x } }]] } } }][-> p {
-> x { p[x] } }][-> p { -> x {p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[
p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[
p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[
p[p[p[p[p[p[p[p[p[p[x]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]} }]][-> n { -> b {
b }[-> n { n[-> x { -> x { -> y { y } } }][-> x { -> y { x } }] }[-> f
{ -> x { f[-> y { x[x][y] }] }[-> x { f[-> y { x[x][y] }] }] }[-> f {
-> m { -> n { -> b { b }[-> m { -> n { -> n { n[-> x { -> x { -> y { y
} } }][-> x { -> y { x } }] }[-> m { -> n { n[-> n { -> f { -> x {
n[-> g { -> h { h[g[f]] } }][-> y { x }][-> y { y }] } } }][m] }
METHOD
HANDLES
INVOKEDYNAMIC
           [bootstrapMethod]


bootstrapMethod():
                           Call Site
  CallSite (once)
                                target

                           Method
                           Handle
package java.lang.invoke;

public abstract class MethodHandle {
    public final native Object invoke(Object... args)
        throws Throwable;
}
LAMBDA
  p[x]
methodHandle.invoke(x);
java.lang.invoke.
       MethodHandles
 arrayElementGetter arrayElementSetter
   spreadInvoker exactInvoker invoker
explicitCastArguments permuteArguments
    constant identity insertArguments
       dropArguments dropArguments
    filterArguments filterReturnValue
       foldArguments guardWithTest
      catchException throwException
String literal
 Constant lookup
  Other literals
Instance variables
Method invocation
 Math operations
IT’S A JVM
  WORLD
DRIVE JAVA
FROM RUBY
require 'java'
require 'rubygems'
require 'flying_saucer'

java_import org.xhtmlrenderer.pdf.ITextRenderer

document = <<-HTML
<html><body><h1>Hello Flying Saucer!</h1></body></html>
HTML

File.open("doc.pdf", "wb") do |out|
  renderer = ITextRenderer.new
  renderer.set_document_from_string document
  renderer.layout
  renderer.create_pdf out.to_outputstream
end

system("open doc.pdf")



 jruby -S gem install flying_saucer to try this example.
$ jruby saucer.rb
DECORATE
JAVA OBJECTS
 WITH JRUBY
module java::util::Iterator
  include Enumerable

  def each
    while has_next
      yield self.next
    end
  end
end
DRIVE RUBY
   FROM JAVA
(org.jruby.embed)
import org.jruby.embed.ScriptingContainer;

public class EmbedJRuby {
    public static void main(String[] args) {
        ScriptingContainer container = new ScriptingContainer();
        container.runScriptlet("puts 'Hello from Ruby'");
    }
}



(defn -main
  "Call JRuby!"
  [& args]
  (doto (org.jruby.embed.ScriptingContainer.)
    (.runScriptlet "puts 'Hello from Ruby!'")))
JRuby +
 Clojure
;; examples.clj
(def hmap (hash-map "foo" "FOO"
                    "bar" "BAR"
                    "baz" "BAZ"))

(println hmap)
(println (get hmap "bar"))
(println (contains? hmap "foo"))
# ruby
Java::clojure.main.main(["./examples.clj"])
github.com/
  daveray/
  familiar
Familiar.with do
  # clojure.core functions here
  # ‘-’ replaced with ‘_’
  # e.g. hash-map => hash_map
end
Familiar.with do
  r = ref(nil)

  begin
    ref_set r, 'foo'
  rescue
    puts "no transaction! #{$!}"
  end

  dosync do
    ref_set r, 'foo'
  end
  p deref(r)
end
j.mp/
  clojure-
from-jruby
FUTURE
{,bugs,wiki,ci}
   jruby.org
github.com/
    jruby
Thanks!

Weitere ähnliche Inhalte

Was ist angesagt?

Fast as C: How to Write Really Terrible Java
Fast as C: How to Write Really Terrible JavaFast as C: How to Write Really Terrible Java
Fast as C: How to Write Really Terrible JavaCharles Nutter
 
Supercharging reflective libraries with InvokeDynamic
Supercharging reflective libraries with InvokeDynamicSupercharging reflective libraries with InvokeDynamic
Supercharging reflective libraries with InvokeDynamicIan Robertson
 
JVM for Dummies - OSCON 2011
JVM for Dummies - OSCON 2011JVM for Dummies - OSCON 2011
JVM for Dummies - OSCON 2011Charles Nutter
 
Practical Testing of Ruby Core
Practical Testing of Ruby CorePractical Testing of Ruby Core
Practical Testing of Ruby CoreHiroshi SHIBATA
 
Kotlin is charming; The reasons Java engineers should start Kotlin.
Kotlin is charming; The reasons Java engineers should start Kotlin.Kotlin is charming; The reasons Java engineers should start Kotlin.
Kotlin is charming; The reasons Java engineers should start Kotlin.JustSystems Corporation
 
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
 
Making Java Groovy (JavaOne 2013)
Making Java Groovy (JavaOne 2013)Making Java Groovy (JavaOne 2013)
Making Java Groovy (JavaOne 2013)Ken Kousen
 
Clojure and the Web
Clojure and the WebClojure and the Web
Clojure and the Webnickmbailey
 
A million connections and beyond - Node.js at scale
A million connections and beyond - Node.js at scaleA million connections and beyond - Node.js at scale
A million connections and beyond - Node.js at scaleTom Croucher
 
Java libraries you can't afford to miss
Java libraries you can't afford to missJava libraries you can't afford to miss
Java libraries you can't afford to missAndres Almiray
 
mruby で mackerel のプラグインを作るはなし
mruby で mackerel のプラグインを作るはなしmruby で mackerel のプラグインを作るはなし
mruby で mackerel のプラグインを作るはなしHiroshi SHIBATA
 
Node js presentation
Node js presentationNode js presentation
Node js presentationmartincabrera
 
Alfresco the clojure way
Alfresco the clojure wayAlfresco the clojure way
Alfresco the clojure wayCarlo Sciolla
 
Groovy and Grails in Action - Devoxx 2008 - University - Guillaume Laforge
Groovy and Grails in Action - Devoxx 2008 - University - Guillaume LaforgeGroovy and Grails in Action - Devoxx 2008 - University - Guillaume Laforge
Groovy and Grails in Action - Devoxx 2008 - University - Guillaume LaforgeGuillaume Laforge
 
ES2015 (ES6) Overview
ES2015 (ES6) OverviewES2015 (ES6) Overview
ES2015 (ES6) Overviewhesher
 
Oral presentation v2
Oral presentation v2Oral presentation v2
Oral presentation v2Yeqi He
 

Was ist angesagt? (20)

Fast as C: How to Write Really Terrible Java
Fast as C: How to Write Really Terrible JavaFast as C: How to Write Really Terrible Java
Fast as C: How to Write Really Terrible Java
 
Supercharging reflective libraries with InvokeDynamic
Supercharging reflective libraries with InvokeDynamicSupercharging reflective libraries with InvokeDynamic
Supercharging reflective libraries with InvokeDynamic
 
ECMAScript 6
ECMAScript 6ECMAScript 6
ECMAScript 6
 
JVM for Dummies - OSCON 2011
JVM for Dummies - OSCON 2011JVM for Dummies - OSCON 2011
JVM for Dummies - OSCON 2011
 
node ffi
node ffinode ffi
node ffi
 
Practical Testing of Ruby Core
Practical Testing of Ruby CorePractical Testing of Ruby Core
Practical Testing of Ruby Core
 
Kotlin is charming; The reasons Java engineers should start Kotlin.
Kotlin is charming; The reasons Java engineers should start Kotlin.Kotlin is charming; The reasons Java engineers should start Kotlin.
Kotlin is charming; The reasons Java engineers should start Kotlin.
 
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
 
Making Java Groovy (JavaOne 2013)
Making Java Groovy (JavaOne 2013)Making Java Groovy (JavaOne 2013)
Making Java Groovy (JavaOne 2013)
 
Clojure and the Web
Clojure and the WebClojure and the Web
Clojure and the Web
 
A million connections and beyond - Node.js at scale
A million connections and beyond - Node.js at scaleA million connections and beyond - Node.js at scale
A million connections and beyond - Node.js at scale
 
Java libraries you can't afford to miss
Java libraries you can't afford to missJava libraries you can't afford to miss
Java libraries you can't afford to miss
 
mruby で mackerel のプラグインを作るはなし
mruby で mackerel のプラグインを作るはなしmruby で mackerel のプラグインを作るはなし
mruby で mackerel のプラグインを作るはなし
 
Node js presentation
Node js presentationNode js presentation
Node js presentation
 
Alfresco the clojure way
Alfresco the clojure wayAlfresco the clojure way
Alfresco the clojure way
 
Node.js - A Quick Tour
Node.js - A Quick TourNode.js - A Quick Tour
Node.js - A Quick Tour
 
Dispatch in Clojure
Dispatch in ClojureDispatch in Clojure
Dispatch in Clojure
 
Groovy and Grails in Action - Devoxx 2008 - University - Guillaume Laforge
Groovy and Grails in Action - Devoxx 2008 - University - Guillaume LaforgeGroovy and Grails in Action - Devoxx 2008 - University - Guillaume Laforge
Groovy and Grails in Action - Devoxx 2008 - University - Guillaume Laforge
 
ES2015 (ES6) Overview
ES2015 (ES6) OverviewES2015 (ES6) Overview
ES2015 (ES6) Overview
 
Oral presentation v2
Oral presentation v2Oral presentation v2
Oral presentation v2
 

Ähnlich wie JRuby @ Boulder Ruby

JRuby 9000 - Taipei Ruby User's Group 2015
JRuby 9000 - Taipei Ruby User's Group 2015JRuby 9000 - Taipei Ruby User's Group 2015
JRuby 9000 - Taipei Ruby User's Group 2015Charles Nutter
 
Практики применения JRuby
Практики применения JRubyПрактики применения JRuby
Практики применения JRuby.toster
 
Aloha RubyConf 2012 - JRuby
Aloha RubyConf 2012 - JRubyAloha RubyConf 2012 - JRuby
Aloha RubyConf 2012 - JRubyCharles Nutter
 
Jruby synergy-of-ruby-and-java
Jruby synergy-of-ruby-and-javaJruby synergy-of-ruby-and-java
Jruby synergy-of-ruby-and-javaKeith Bennett
 
Hacking with ruby2ruby
Hacking with ruby2rubyHacking with ruby2ruby
Hacking with ruby2rubyMarc Chung
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing UpDavid Padbury
 
Developing cross platform desktop application with Ruby
Developing cross platform desktop application with RubyDeveloping cross platform desktop application with Ruby
Developing cross platform desktop application with RubyAnis Ahmad
 
The Enterprise Strikes Back
The Enterprise Strikes BackThe Enterprise Strikes Back
The Enterprise Strikes BackBurke Libbey
 
JRuby - Programmer's Best Friend on JVM
JRuby - Programmer's Best Friend on JVMJRuby - Programmer's Best Friend on JVM
JRuby - Programmer's Best Friend on JVMRaimonds Simanovskis
 
2007 09 10 Fzi Training Groovy Grails V Ws
2007 09 10 Fzi Training Groovy Grails V Ws2007 09 10 Fzi Training Groovy Grails V Ws
2007 09 10 Fzi Training Groovy Grails V Wsloffenauer
 
How to Begin Developing Ruby Core
How to Begin Developing Ruby CoreHow to Begin Developing Ruby Core
How to Begin Developing Ruby CoreHiroshi SHIBATA
 
JRuby - Enterprise 2.0
JRuby - Enterprise 2.0JRuby - Enterprise 2.0
JRuby - Enterprise 2.0Jan Sifra
 
Adopting GraalVM - Scale by the Bay 2018
Adopting GraalVM - Scale by the Bay 2018Adopting GraalVM - Scale by the Bay 2018
Adopting GraalVM - Scale by the Bay 2018Petr Zapletal
 
Java 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from OredevJava 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from OredevMattias Karlsson
 
Quick Intro To JRuby
Quick Intro To JRubyQuick Intro To JRuby
Quick Intro To JRubyFrederic Jean
 
Torquebox OSCON Java 2011
Torquebox OSCON Java 2011Torquebox OSCON Java 2011
Torquebox OSCON Java 2011tobiascrawley
 

Ähnlich wie JRuby @ Boulder Ruby (20)

JRuby 9000 - Taipei Ruby User's Group 2015
JRuby 9000 - Taipei Ruby User's Group 2015JRuby 9000 - Taipei Ruby User's Group 2015
JRuby 9000 - Taipei Ruby User's Group 2015
 
Практики применения JRuby
Практики применения JRubyПрактики применения JRuby
Практики применения JRuby
 
Aloha RubyConf 2012 - JRuby
Aloha RubyConf 2012 - JRubyAloha RubyConf 2012 - JRuby
Aloha RubyConf 2012 - JRuby
 
Clojure And Swing
Clojure And SwingClojure And Swing
Clojure And Swing
 
Profiling Ruby
Profiling RubyProfiling Ruby
Profiling Ruby
 
Jruby synergy-of-ruby-and-java
Jruby synergy-of-ruby-and-javaJruby synergy-of-ruby-and-java
Jruby synergy-of-ruby-and-java
 
Hacking with ruby2ruby
Hacking with ruby2rubyHacking with ruby2ruby
Hacking with ruby2ruby
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing Up
 
Developing cross platform desktop application with Ruby
Developing cross platform desktop application with RubyDeveloping cross platform desktop application with Ruby
Developing cross platform desktop application with Ruby
 
The Enterprise Strikes Back
The Enterprise Strikes BackThe Enterprise Strikes Back
The Enterprise Strikes Back
 
Practical JRuby
Practical JRubyPractical JRuby
Practical JRuby
 
JRuby - Programmer's Best Friend on JVM
JRuby - Programmer's Best Friend on JVMJRuby - Programmer's Best Friend on JVM
JRuby - Programmer's Best Friend on JVM
 
2007 09 10 Fzi Training Groovy Grails V Ws
2007 09 10 Fzi Training Groovy Grails V Ws2007 09 10 Fzi Training Groovy Grails V Ws
2007 09 10 Fzi Training Groovy Grails V Ws
 
How to Begin Developing Ruby Core
How to Begin Developing Ruby CoreHow to Begin Developing Ruby Core
How to Begin Developing Ruby Core
 
JRuby - Enterprise 2.0
JRuby - Enterprise 2.0JRuby - Enterprise 2.0
JRuby - Enterprise 2.0
 
Groovy
GroovyGroovy
Groovy
 
Adopting GraalVM - Scale by the Bay 2018
Adopting GraalVM - Scale by the Bay 2018Adopting GraalVM - Scale by the Bay 2018
Adopting GraalVM - Scale by the Bay 2018
 
Java 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from OredevJava 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from Oredev
 
Quick Intro To JRuby
Quick Intro To JRubyQuick Intro To JRuby
Quick Intro To JRuby
 
Torquebox OSCON Java 2011
Torquebox OSCON Java 2011Torquebox OSCON Java 2011
Torquebox OSCON Java 2011
 

Kürzlich hochgeladen

WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 

Kürzlich hochgeladen (20)

WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 

JRuby @ Boulder Ruby

  • 2.
  • 5. Best of Ruby and Java... Together!
  • 8. runs nearly all pure ruby code runs 92% of rubyspec suite runs ~30% of 1.9 test suite (even more with 1.8 mode)
  • 9. http://jruby.org/download rvm install jruby INSTALL gem install jruby-lint $ jrlint
  • 13. GC.pauses = “no thanks”
  • 14. class Simple   attr_accessor :next end top = Simple.new puts Benchmark.measure {   outer = 10   total = 100000   per = 100   outer.times do     total.times do       per.times { Simple.new }       s = Simple.new       top.next = s       top = s     end   end }
  • 15. Ruby 1.9.3 JRuby 8000 6000 4000 2000 0 GC count
  • 16. Ruby 1.9.3 JRuby 10000 1000 100 10 1 GC count
  • 17. 15 Ruby 1.9.3 JRuby 12 9 6 3 0 GC time %
  • 18. Time per GC versus heap usage 300ms Ruby 2.0.0 JRuby 225ms 150ms 75ms 0ms 188KB/29MB 27MB/127MB 199MB/238MB Heap usage (MRI/JRuby)
  • 20. Ruby 1.9 Ruby 1.9 unthreaded threaded JRuby JRuby unthreaded threaded
  • 21. sidekiq.org What if 1 Sidekiq process could do the work of 20 Resque or DelayedJob processes?
  • 23. Ruby application code JVM bytecode Key Native code Ruby Ruby Ruby code code code Ruby Ruby JRuby JRuby JRuby code code Ruby JVM JVM JRuby JVM JRuby code Full interpretation JRuby compiler HotSpot compiler Time
  • 25. Red-Black Tree 5 4 ruby 1.9.3p286 jruby 1.7.0 java 1.6.0_29 3 jruby 1.7.0 java 1.7.0_09 jruby 1.7.0 java 1.7.0_09-b05 +indy 2 1 0
  • 26. Times Faster than Ruby 1.9.3 5 JRuby/Java 6 JRuby/Java 7+indy 4.226 4.32 3.75 3.66 3.44 2.5 2.658 1.914 1.806 1.25 1.538 1.565 1.346 0 base64 richards neural mandelbrot redblack
  • 28. Get JDK 7 (OSX too!) java.oracle.com
  • 30. experthuman.com/ programming-with- nothing Tom Stuart @tomstuart
  • 34. (1..100).each do |n| if (n % 15).zero? puts 'FizzBuzz' elsif (n % 3).zero? puts 'Fizz' elsif (n % 5).zero? puts 'Buzz' else puts n.to_s end end
  • 35. fizzbuzz = -> k { -> f { -> f { -> x { f[-> y { x[x][y] }] }[-> x { f[-> y { x[x][y] }] }] }[-> f { -> l { -> x { -> g { -> b { b }[-> p { p[-> x { -> y { x } } ] }[l]][x][-> y { g[f[-> l { -> p { p[-> x { -> y { y } } ] }[-> p { p[-> x { -> y { y } } ] }[l]] }[l]][x][g]][-> l { -> p { p[-> x { -> y { x } } ] }[-> p { p[-> x { -> y { y } } ] }[l]] }[l]][y] }] } } } }][k][-> x { -> y { -> f { f[x][y] } } }[-> x { -> y { x } }][-> x { -> y { x } }]][-> l { -> x { -> l { -> x { -> x { -> y { -> f { f[x][y] } } }[-> x { -> y { y } }][-> x { -> y { -> f { f[x][y] } } }[x][l]] } }[l][f[x]] } }] } }[-> f { -> x { f[-> y { x[x][y] }] }[-> x { f[-> y { x[x][y] }] }] }[-> f { -> m { -> n { -> b { b }[-> m { -> n { -> n { n[-> x { -> x { -> y { y } } }][-> x { -> y { x } }] }[-> m { -> n { n[-> n { -> f { -> x { n[-> g { -> h { h[g[f]] } }][-> y { x }][-> y { y }] } } }][m] } }[m][n]] } }[m][n]][-> x { -> l { -> x { -> x { -> y { -> f { f[x][y] } } }[-> x { -> y { y } }][-> x { -> y { -> f { f[x][y] } } }[x][l]] } }[f[-> n { -> p { -> x { p[n[p][x]] } } }[m]][n]][m][x] }][-> x { -> y { -> f { f[x][y] } } }[-> x { -> y { x } }][-> x { -> y { x } }]] } } }][-> p { -> x { p[x] } }][-> p { -> x {p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[ p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[ p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[p[ p[p[p[p[p[p[p[p[p[p[x]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]] ]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]} }]][-> n { -> b { b }[-> n { n[-> x { -> x { -> y { y } } }][-> x { -> y { x } }] }[-> f { -> x { f[-> y { x[x][y] }] }[-> x { f[-> y { x[x][y] }] }] }[-> f { -> m { -> n { -> b { b }[-> m { -> n { -> n { n[-> x { -> x { -> y { y } } }][-> x { -> y { x } }] }[-> m { -> n { n[-> n { -> f { -> x { n[-> g { -> h { h[g[f]] } }][-> y { x }][-> y { y }] } } }][m] }
  • 37. INVOKEDYNAMIC [bootstrapMethod] bootstrapMethod(): Call Site CallSite (once) target Method Handle
  • 38. package java.lang.invoke; public abstract class MethodHandle { public final native Object invoke(Object... args) throws Throwable; }
  • 41. java.lang.invoke. MethodHandles arrayElementGetter arrayElementSetter spreadInvoker exactInvoker invoker explicitCastArguments permuteArguments constant identity insertArguments dropArguments dropArguments filterArguments filterReturnValue foldArguments guardWithTest catchException throwException
  • 42. String literal Constant lookup Other literals Instance variables Method invocation Math operations
  • 43. IT’S A JVM WORLD
  • 45. require 'java' require 'rubygems' require 'flying_saucer' java_import org.xhtmlrenderer.pdf.ITextRenderer document = <<-HTML <html><body><h1>Hello Flying Saucer!</h1></body></html> HTML File.open("doc.pdf", "wb") do |out| renderer = ITextRenderer.new renderer.set_document_from_string document renderer.layout renderer.create_pdf out.to_outputstream end system("open doc.pdf") jruby -S gem install flying_saucer to try this example.
  • 48. module java::util::Iterator include Enumerable def each while has_next yield self.next end end end
  • 49. DRIVE RUBY FROM JAVA (org.jruby.embed)
  • 50. import org.jruby.embed.ScriptingContainer; public class EmbedJRuby { public static void main(String[] args) { ScriptingContainer container = new ScriptingContainer(); container.runScriptlet("puts 'Hello from Ruby'"); } } (defn -main "Call JRuby!" [& args] (doto (org.jruby.embed.ScriptingContainer.) (.runScriptlet "puts 'Hello from Ruby!'")))
  • 52. ;; examples.clj (def hmap (hash-map "foo" "FOO" "bar" "BAR" "baz" "BAZ")) (println hmap) (println (get hmap "bar")) (println (contains? hmap "foo"))
  • 55. Familiar.with do # clojure.core functions here # ‘-’ replaced with ‘_’ # e.g. hash-map => hash_map end
  • 56. Familiar.with do r = ref(nil) begin ref_set r, 'foo' rescue puts "no transaction! #{$!}" end dosync do ref_set r, 'foo' end p deref(r) end
  • 59.
  • 60. {,bugs,wiki,ci} jruby.org
  • 61. github.com/ jruby