SlideShare una empresa de Scribd logo
1 de 128
JRuby
Практика применения
Short history
Short history

• 2001 - the first version of JRuby(by Jan
  Arne Petersen)
Short history

• 2001 - the first version of JRuby(by Jan
  Arne Petersen)
• 2006 - version 0.9.0(by Charles Nutter,
  Thomas Enebo, Ola Bini and Nick Siege)
Short history

• 2001 - the first version of JRuby(by Jan
  Arne Petersen)
• 2006 - version 0.9.0(by Charles Nutter,
  Thomas Enebo, Ola Bini and Nick Siege)
• 2007 - version 1.0(passed all Rails tests)
Why JRuby?
Why JRuby?
• Multithreading
Why JRuby?
• Multithreading
• JVM
Why JRuby?
• Multithreading
• JVM
• Cross-platform
Why JRuby?
• Multithreading
• JVM
• Cross-platform
• Just another .jar
Why JRuby?
• Multithreading
• JVM
• Cross-platform
• Just another .jar
• GUI
Why JRuby?
• Multithreading
• JVM
• Cross-platform
• Just another .jar
• GUI
• Android
JVM
JVM

• Concurrent threading
JVM

• Concurrent threading
• Garbage collectors
JVM

• Concurrent threading
• Garbage collectors
• JIT compiler
JVM

• Concurrent threading
• Garbage collectors
• JIT compiler
• invokedynamic(JDK 7)
Missing features
Missing features
• Memory footprint
Missing features
• Memory footprint
• No Kernel#fork
Missing features
• Memory footprint
• No Kernel#fork
• No continuations(callcc)
Missing features
• Memory footprint
• No Kernel#fork
• No continuations(callcc)
• ObjectSpace off by default(-X+O to enable)
Missing features
• Memory footprint
• No Kernel#fork
• No continuations(callcc)
• ObjectSpace off by default(-X+O to enable)
• set_trace_func off by default(--debug to
  enable)
C extensions


since JRuby 1.6(still experimental)
Easy installing

• rvm install jruby
• rbenv install jruby-1.6.6 (*)
• Download from http://jruby.org
Compatibilities


 Ruby 1.8.7 & 1.9.2 compatible
              (default 1.8)
flag `jruby --1.9` for 1.9.2 compatibility
Nailgun
(since 1.3.0 version)
Nailgun
             (since 1.3.0 version)

Nailgun is a client, protocol, and server for
   running Java programs in the server.
Nailgun
             (since 1.3.0 version)

Nailgun is a client, protocol, and server for
   running Java programs in the server.


          $ jruby --ng-server &
          $ jruby --ng -e "puts 1"
Multi-VM support
  many apps in one process
Multi-VM support
  many apps in one process




            JVM
Multi-VM support
        many apps in one process


JRuby      JRuby   JRuby   JRuby   JRuby




                   JVM
Benchmarks
jruby 1.7.0.dev(JDK 6)   jruby 1.7.0.dev(JDK 7) invokedynamic=false
jruby 1.7.0.dev(JDK 7)   ruby 1.9.3-p0
Benchmarks
    jruby 1.7.0.dev(JDK 6)           jruby 1.7.0.dev(JDK 7) invokedynamic=false
    jruby 1.7.0.dev(JDK 7)           ruby 1.9.3-p0

4


3


2


1


0
                             bench/bench_red_black.rb (sec)
Benchmarks
    jruby 1.7.0.dev(JDK 6)           jruby 1.7.0.dev(JDK 7) invokedynamic=false
    jruby 1.7.0.dev(JDK 7)           ruby 1.9.3-p0

4


3


2


1


0
                             bench/bench_red_black.rb (sec)
Benchmarks
    jruby 1.7.0.dev(JDK 6)           jruby 1.7.0.dev(JDK 7) invokedynamic=false
    jruby 1.7.0.dev(JDK 7)           ruby 1.9.3-p0

4


3


2


1


0
                             bench/bench_red_black.rb (sec)
Benchmarks
    jruby 1.7.0.dev(JDK 6)           jruby 1.7.0.dev(JDK 7) invokedynamic=false
    jruby 1.7.0.dev(JDK 7)           ruby 1.9.3-p0

4


3


2


1


0
                             bench/bench_red_black.rb (sec)
Benchmarks
    jruby 1.7.0.dev(JDK 6)           jruby 1.7.0.dev(JDK 7) invokedynamic=false
    jruby 1.7.0.dev(JDK 7)           ruby 1.9.3-p0

4


3


2


1


0
                             bench/bench_red_black.rb (sec)
jvisualvm
jvisualvm
jvisualvm
JVM + JRuby
JVM + JRuby

• Swing, SWT
JVM + JRuby

• Swing, SWT
• JavaFX
JVM + JRuby

• Swing, SWT
• JavaFX
• Spring & Hibernate
JVM + JRuby

• Swing, SWT
• JavaFX
• Spring & Hibernate
• Scala, Groovy, Jython, Clojure, ...
JVM + JRuby
    Swing
JVM + JRuby
    Swing
RedCar
  SWT
Java + Ruby
Java + Ruby
• require ‘java’
Java + Ruby
• require ‘java’
• Java namespace
Java + Ruby
• require ‘java’
• Java namespace
• Snake case(get_some vs getSome)
Java + Ruby
• require ‘java’
• Java namespace
• Snake case(get_some vs getSome)
• Ruby-style accessors(length= vs setLength)
Java + Ruby
• require ‘java’
• Java namespace
• Snake case(get_some vs getSome)
• Ruby-style accessors(length= vs setLength)
• Converting types
Java + Ruby
• require ‘java’
• Java namespace
• Snake case(get_some vs getSome)
• Ruby-style accessors(length= vs setLength)
• Converting types
• Swing IRB(command: jirb_swing)
Java bridge
  Collections
Java bridge
                 Collections


Java List:
java_list[0]
java_list << 5
java_list += 7
Java bridge
                 Collections


Java List:             Java Map:
java_list[0]           java_list[‘key’]
java_list << 5         java_list[‘key’] = 5
java_list += 7
Java bridge
                 Collections


Java List:             Java Map:
java_list[0]           java_list[‘key’]
java_list << 5         java_list[‘key’] = 5
java_list += 7

         Ruby List:
         [1, 2, 3].to_java :int
         [“string”].to_java :string
Java bridge
                Overloading


Java:
public class Test {
  public boolean isSome(String arg) {...}
  public boolean isSome(int arg) {...}
  public boolean isSome(long arg) {...}
  public boolean isSome(Object arg) {...}
}
Java bridge
                    Overloading


Ruby:
Test.new.java_send :isSome, [Java::long], 1_000
or
class Test
  java_alias :is_some, :isSome, [Java::long]
  ...
end
Java bridge
               Annotations



Java:
@Bean(scope = Scope.PROTOTYPE)
public class Person {
    ...
}
Java bridge
                    Annotations

Ruby:
java_import Bean
java_import Scope

class Person
end

Person.add_class_annotation(Bean: {
   ‘scope’ => Scope.PROTOTYPE
})
Person.become_java!
Java bridge
            Interfaces




Ruby:
class Posts
  include java.util.Iterator
end
JRuby compiler
           Ahead-Of-Time Compilation

$ jrubyc <script name>.rb
$ java -cp .:/path/to/jruby.jar <script name>
JRuby compiler
         Generate .java classes from .rb

$ jrubyc --java <script name>.rb
JRuby compiler

Ruby:
require 'java'

class Vec
  def initialize(x, y)
   @xcoord = x
   @ycoord = y
  end
end
JRuby compiler
Ruby:
require 'java'

class Vec
  java_signature 'Vec(double x, double y)'
  def initialize(x, y)
    @xcoord = x
    @ycoord = y
  end
end
JRuby compiler
Java:
import org.jruby.Ruby;
import org.jruby.RubyObject;
import org.jruby.RubyClass;
...
public class Vec extends RubyObject {
   ...
   public Vec(double x, double y) {
      ...
   }
}
Rake + Ant
Rake + Ant

Ant tasks like Rake tasks:
task :ant_import do
  ant_import
end
Buildr
                 http://buildr.apache.org



    Apache Buildr is a build system for Java-based
applications, including support for Scala, Groovy and a
     growing number of JVM languages and tools.
Buildr
http://buildr.apache.org
Buildr
              http://buildr.apache.org


•   Projects and sub-projects
Buildr
              http://buildr.apache.org


•   Projects and sub-projects
•   Compiling, copying and filtering resources,
    test cases, Javadoc and more
Buildr
              http://buildr.apache.org


•   Projects and sub-projects
•   Compiling, copying and filtering resources,
    test cases, Javadoc and more
•   Builds what has changed since the last release
Buildr
              http://buildr.apache.org


•   Projects and sub-projects
•   Compiling, copying and filtering resources,
    test cases, Javadoc and more
•   Builds what has changed since the last release
•   Support Maven 2.0
Buildr
              http://buildr.apache.org


•   Projects and sub-projects
•   Compiling, copying and filtering resources,
    test cases, Javadoc and more
•   Builds what has changed since the last release
•   Support Maven 2.0
•   Support Ant
Buildr
              http://buildr.apache.org


•   Projects and sub-projects
•   Compiling, copying and filtering resources,
    test cases, Javadoc and more
•   Builds what has changed since the last release
•   Support Maven 2.0
•   Support Ant
•   Buildr is Ruby all the way down
Buildr
                               http://buildr.apache.org
buildfile:
repositories.remote "http://repo.typesafe.com/typesafe/releases/"

desc "The Springmongodb project"
define "SpringMongoDB" do
 project.version = "0.1"
 project.group = "SpringMongoDB"

 run.with "org.jruby:jruby-complete:jar:1.6.6",
       "org.mongodb:mongo-java-driver:jar:2.7.2",
       "org.springframework:spring-core:jar:3.1.0.RELEASE",
       "org.springframework:spring-context:jar:3.1.0.RELEASE",
       "org.springframework:spring-beans:jar:3.1.0.RELEASE",
       'org.springframework.data:spring-data-commons-core:jar:1.1.0.RELEASE',
       "org.springframework.data:spring-data-mongodb:jar:1.0.0.RC1"

 run.using main: ['org.jruby.Main', _(:src, :main, :ruby, "app.rb")]
end
Rawr
                    http://rawr.rubyforge.org




Rawr, a packaging and deployment tool, that allows turns your
code into an executable jar, a .exe for Windows, and a .app for
OS X.
Rawr
http://rawr.rubyforge.org


 $ gem install rawr
 $ rawr install
 ...
 $ rake rawr:jar
Deployment
JRuby-Rack

 Servlet     JRuby-Rack               Rack
                            Rack
container   servlet filter          application
JRuby servers
JRuby servers

    WEBrick
JRuby servers

    WEBrick

    Trinidad
JRuby servers

    WEBrick

    Trinidad

   TorqueBox
TorqueBox
http://torquebox.org
TorqueBox
http://torquebox.org
TorqueBox
                http://torquebox.org




Installation:
jruby -S gem install torquebox-server --pre
TorqueBox
        http://torquebox.org




Usage:
torquebox deploy ~/Projects/rails_app
torquebox run
Warbler

 Warbler is a gem to make a Java jar or war file
out of any Ruby, Rails, Merb, or Rack application.
Warbler

Installation:
jruby -S gem install warbler
Warbler
Usage:
Warbler
Warbler
Standalone application:
Tuning flags
Tuning flags

• --server - server compiler
Tuning flags

• --server - server compiler
• -Xmx - max heap size
Tuning flags

• --server - server compiler
• -Xmx - max heap size
• -XX:+UnlockExperimentalVMOptions
  -XX:+UseG1GC - new GC(JDK 7)
Clouds
• Amazon Elastic Beans(http://aws.amazon.com/
  elasticbeanstalk/)

• Jelastic(http://jelastic.com)
• Engine Yard(http://www.engineyard.com)
• Google App Engine(http://
  appengine.google.com)
Hot Spot
Bot Hunter
Bot Hunter


• Multithreading
Bot Hunter


• Multithreading
• Some logic on Scala
Yukihiro Matsumoto: “I would remove the
thread and add actors or some other more
advanced concurrency features”.
Akka
              http://akka.io/



Simpler Concurrency, Scalability & Fault-
       tolerance through Actors




                                    slidesha.re/akka-scala-days-2010
Actor Model of
 Concurrency




             slidesha.re/akka-scala-days-2010
Actor Model of
        Concurrency
• Implements Message-Passing Concurrency




                                   slidesha.re/akka-scala-days-2010
Actor Model of
        Concurrency
• Implements Message-Passing Concurrency
• Share nothing




                                   slidesha.re/akka-scala-days-2010
Actor Model of
        Concurrency
• Implements Message-Passing Concurrency
• Share nothing
• Isolated lightweight process


                                   slidesha.re/akka-scala-days-2010
Actor Model of
        Concurrency
• Implements Message-Passing Concurrency
• Share nothing
• Isolated lightweight process
• Communicates through messages

                                   slidesha.re/akka-scala-days-2010
Actor Model of
        Concurrency
• Implements Message-Passing Concurrency
• Share nothing
• Isolated lightweight process
• Communicates through messages
• Asynchronous and non-blocking
                                   slidesha.re/akka-scala-days-2010
Actor Model of
        Concurrency
• Implements Message-Passing Concurrency
• Share nothing
• Isolated lightweight process
• Communicates through messages
• Asynchronous and non-blocking
• Each actor has a mailbox(message queue)
                                    slidesha.re/akka-scala-days-2010
Two different models




                 slidesha.re/akka-scala-days-2010
Two different models

• Thread-based




                  slidesha.re/akka-scala-days-2010
Two different models

• Thread-based
• Event-based



                  slidesha.re/akka-scala-days-2010
Two different models

• Thread-based
• Event-based
 • Very lightweight(~300 bytes per actor)


                                   slidesha.re/akka-scala-days-2010
Two different models

• Thread-based
• Event-based
 • Very lightweight(~300 bytes per actor)
 • Can easily create millions on a single
    workstation


                                   slidesha.re/akka-scala-days-2010
Example


          slidesha.re/akka-scala-days-2010
Server code
class HelloWorldActor extends UntypedActor {
  public void onReceive(Object msg) {
     getContext().tryReply(msg + " World");
  }
}
remote().start("localhost", 2552).register(
  "hello-service",
    actorOf(HelloWorldActor.class));




                                         slidesha.re/akka-scala-days-2010
Client code

actor = Actors.remote.actorFor(
  "hello-service", "localhost", 2552)
res = actor.ask("Hello").get




                                        slidesha.re/akka-scala-days-2010
The Bad
java.lang.NullPointerException
Groovy
Questions?


Email: klimtimothy@gmail.com

Más contenido relacionado

La actualidad más candente

TorqueBox - Ultrapassando a fronteira entre Java e Ruby
TorqueBox - Ultrapassando a fronteira entre Java e RubyTorqueBox - Ultrapassando a fronteira entre Java e Ruby
TorqueBox - Ultrapassando a fronteira entre Java e Ruby
Bruno Oliveira
 
TorqueBox - When Java meets Ruby
TorqueBox - When Java meets RubyTorqueBox - When Java meets Ruby
TorqueBox - When Java meets Ruby
Bruno Oliveira
 
スローダウン、ハングを一発解決 スレッドダンプはトラブルシューティングの味方 #wlstudy
スローダウン、ハングを一発解決 スレッドダンプはトラブルシューティングの味方 #wlstudyスローダウン、ハングを一発解決 スレッドダンプはトラブルシューティングの味方 #wlstudy
スローダウン、ハングを一発解決 スレッドダンプはトラブルシューティングの味方 #wlstudy
Yusuke Yamamoto
 
Torquebox - O melhor dos dois mundos
Torquebox - O melhor dos dois mundosTorquebox - O melhor dos dois mundos
Torquebox - O melhor dos dois mundos
Bruno Oliveira
 

La actualidad más candente (20)

TorqueBox - Ultrapassando a fronteira entre Java e Ruby
TorqueBox - Ultrapassando a fronteira entre Java e RubyTorqueBox - Ultrapassando a fronteira entre Java e Ruby
TorqueBox - Ultrapassando a fronteira entre Java e Ruby
 
The Enterprise Strikes Back
The Enterprise Strikes BackThe Enterprise Strikes Back
The Enterprise Strikes Back
 
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
 
JRuby and Invokedynamic - Japan JUG 2015
JRuby and Invokedynamic - Japan JUG 2015JRuby and Invokedynamic - Japan JUG 2015
JRuby and Invokedynamic - Japan JUG 2015
 
Ruby on Rails survival guide of an aged Java developer
Ruby on Rails survival guide of an aged Java developerRuby on Rails survival guide of an aged Java developer
Ruby on Rails survival guide of an aged Java developer
 
TorqueBox - When Java meets Ruby
TorqueBox - When Java meets RubyTorqueBox - When Java meets Ruby
TorqueBox - When Java meets Ruby
 
スローダウン、ハングを一発解決 スレッドダンプはトラブルシューティングの味方 #wlstudy
スローダウン、ハングを一発解決 スレッドダンプはトラブルシューティングの味方 #wlstudyスローダウン、ハングを一発解決 スレッドダンプはトラブルシューティングの味方 #wlstudy
スローダウン、ハングを一発解決 スレッドダンプはトラブルシューティングの味方 #wlstudy
 
Oscon Java Testing on the Fast Lane
Oscon Java Testing on the Fast LaneOscon Java Testing on the Fast Lane
Oscon Java Testing on the Fast Lane
 
TorqueBox at DC:JBUG - November 2011
TorqueBox at DC:JBUG - November 2011TorqueBox at DC:JBUG - November 2011
TorqueBox at DC:JBUG - November 2011
 
Devignition 2011
Devignition 2011Devignition 2011
Devignition 2011
 
Down the Rabbit Hole: An Adventure in JVM Wonderland
Down the Rabbit Hole: An Adventure in JVM WonderlandDown the Rabbit Hole: An Adventure in JVM Wonderland
Down the Rabbit Hole: An Adventure in JVM Wonderland
 
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
 
A new execution model for Nashorn in Java 9
A new execution model for Nashorn in Java 9A new execution model for Nashorn in Java 9
A new execution model for Nashorn in Java 9
 
TorqueBox: The beauty of Ruby with the power of JBoss. Presented at Devnexus...
TorqueBox: The beauty of Ruby with the power of JBoss.  Presented at Devnexus...TorqueBox: The beauty of Ruby with the power of JBoss.  Presented at Devnexus...
TorqueBox: The beauty of Ruby with the power of JBoss. Presented at Devnexus...
 
Lagergren jvmls-2014-final
Lagergren jvmls-2014-finalLagergren jvmls-2014-final
Lagergren jvmls-2014-final
 
Java Runtime: повседневные обязанности JVM
Java Runtime: повседневные обязанности JVMJava Runtime: повседневные обязанности JVM
Java Runtime: повседневные обязанности JVM
 
Torquebox - O melhor dos dois mundos
Torquebox - O melhor dos dois mundosTorquebox - O melhor dos dois mundos
Torquebox - O melhor dos dois mundos
 
Complex Made Simple: Sleep Better with TorqueBox
Complex Made Simple: Sleep Better with TorqueBoxComplex Made Simple: Sleep Better with TorqueBox
Complex Made Simple: Sleep Better with TorqueBox
 
Embedded systems
Embedded systems Embedded systems
Embedded systems
 
Beyond JVM - YOW Melbourne 2013
Beyond JVM - YOW Melbourne 2013Beyond JVM - YOW Melbourne 2013
Beyond JVM - YOW Melbourne 2013
 

Destacado

Project management mistakes to avoid
Project management mistakes to avoidProject management mistakes to avoid
Project management mistakes to avoid
ramsaas
 
Борис Лепинских. Выступление на FailConf-2013
Борис Лепинских. Выступление на FailConf-2013Борис Лепинских. Выступление на FailConf-2013
Борис Лепинских. Выступление на FailConf-2013
it-people
 
Лев Плинер "О лидерстве в софт-деве"
Лев Плинер "О лидерстве в софт-деве"Лев Плинер "О лидерстве в софт-деве"
Лев Плинер "О лидерстве в софт-деве"
it-people
 
Readings essential standards for prep 2
Readings essential standards for prep 2Readings essential standards for prep 2
Readings essential standards for prep 2
Melissawelch
 

Destacado (7)

Attributes Unwrapped: Lessons under the surface of active record
Attributes Unwrapped: Lessons under the surface of active recordAttributes Unwrapped: Lessons under the surface of active record
Attributes Unwrapped: Lessons under the surface of active record
 
Marketing your Business with Social Media
Marketing your Business with Social Media Marketing your Business with Social Media
Marketing your Business with Social Media
 
Project management mistakes to avoid
Project management mistakes to avoidProject management mistakes to avoid
Project management mistakes to avoid
 
Борис Лепинских. Выступление на FailConf-2013
Борис Лепинских. Выступление на FailConf-2013Борис Лепинских. Выступление на FailConf-2013
Борис Лепинских. Выступление на FailConf-2013
 
Лев Плинер "О лидерстве в софт-деве"
Лев Плинер "О лидерстве в софт-деве"Лев Плинер "О лидерстве в софт-деве"
Лев Плинер "О лидерстве в софт-деве"
 
Readings essential standards for prep 2
Readings essential standards for prep 2Readings essential standards for prep 2
Readings essential standards for prep 2
 
Online collaboration and Building Online Community
Online collaboration and Building Online CommunityOnline collaboration and Building Online Community
Online collaboration and Building Online Community
 

Similar a Практики применения JRuby

Jruby synergy-of-ruby-and-java
Jruby synergy-of-ruby-and-javaJruby synergy-of-ruby-and-java
Jruby synergy-of-ruby-and-java
Keith Bennett
 
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
Nick Sieger
 
Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...
Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...
Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...
Paul King
 
JRuby - Enterprise 2.0
JRuby - Enterprise 2.0JRuby - Enterprise 2.0
JRuby - Enterprise 2.0
Jan Sifra
 
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
Evgeny Rahman
 
JRuby on Rails Deployment: What They Didn't Tell You
JRuby on Rails Deployment: What They Didn't Tell YouJRuby on Rails Deployment: What They Didn't Tell You
JRuby on Rails Deployment: What They Didn't Tell You
elliando dias
 

Similar a Практики применения JRuby (20)

Introduction to JRuby
Introduction to JRubyIntroduction to JRuby
Introduction to JRuby
 
Jruby synergy-of-ruby-and-java
Jruby synergy-of-ruby-and-javaJruby synergy-of-ruby-and-java
Jruby synergy-of-ruby-and-java
 
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
 
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
 
Euruko 2012 - JRuby
Euruko 2012 - JRubyEuruko 2012 - JRuby
Euruko 2012 - JRuby
 
First Day With J Ruby
First Day With J RubyFirst Day With J Ruby
First Day With J Ruby
 
Practical JRuby
Practical JRubyPractical JRuby
Practical JRuby
 
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
 
Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...
Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...
Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...
 
Ugo Cei Presentation
Ugo Cei PresentationUgo Cei Presentation
Ugo Cei Presentation
 
Node js实践
Node js实践Node js实践
Node js实践
 
JRuby: What's Different (RORO Melbourne October 2011)
JRuby: What's Different (RORO Melbourne October 2011)JRuby: What's Different (RORO Melbourne October 2011)
JRuby: What's Different (RORO Melbourne October 2011)
 
JRuby @ Boulder Ruby
JRuby @ Boulder RubyJRuby @ Boulder Ruby
JRuby @ Boulder Ruby
 
JRuby - Enterprise 2.0
JRuby - Enterprise 2.0JRuby - Enterprise 2.0
JRuby - Enterprise 2.0
 
JRuby Basics
JRuby BasicsJRuby Basics
JRuby Basics
 
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
 
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
 
JRuby on Rails Deployment: What They Didn't Tell You
JRuby on Rails Deployment: What They Didn't Tell YouJRuby on Rails Deployment: What They Didn't Tell You
JRuby on Rails Deployment: What They Didn't Tell You
 
Play framework
Play frameworkPlay framework
Play framework
 
Java On Speed
Java On SpeedJava On Speed
Java On Speed
 

Más de .toster

Native look and feel bbui & alicejs
Native look and feel bbui & alicejsNative look and feel bbui & alicejs
Native look and feel bbui & alicejs
.toster
 
Михаил Черномордиков
Михаил ЧерномордиковМихаил Черномордиков
Михаил Черномордиков
.toster
 
Андрей Юношев
Андрей Юношев Андрей Юношев
Андрей Юношев
.toster
 
Алексей Тарасенко - Zeptolab
Алексей Тарасенко - ZeptolabАлексей Тарасенко - Zeptolab
Алексей Тарасенко - Zeptolab
.toster
 
Maximiliano Firtman - Разработка приложений с помощью PhoneGap
Maximiliano Firtman - Разработка приложений с помощью PhoneGap Maximiliano Firtman - Разработка приложений с помощью PhoneGap
Maximiliano Firtman - Разработка приложений с помощью PhoneGap
.toster
 
Вадим Башуров
Вадим БашуровВадим Башуров
Вадим Башуров
.toster
 
Вадим Башуров - Как откусить от яблока лимон
Вадим Башуров - Как откусить от яблока лимонВадим Башуров - Как откусить от яблока лимон
Вадим Башуров - Как откусить от яблока лимон
.toster
 
Вадим Башуров - Как откусить от яблока лимон
Вадим Башуров - Как откусить от яблока лимонВадим Башуров - Как откусить от яблока лимон
Вадим Башуров - Как откусить от яблока лимон
.toster
 
Pablo Villalba -
Pablo Villalba - Pablo Villalba -
Pablo Villalba -
.toster
 
Jordi Romero Api for-the-mobile-era
Jordi Romero Api for-the-mobile-eraJordi Romero Api for-the-mobile-era
Jordi Romero Api for-the-mobile-era
.toster
 
Презентация Юрия Ветрова (Mail.ru Group)
Презентация Юрия Ветрова (Mail.ru Group)Презентация Юрия Ветрова (Mail.ru Group)
Презентация Юрия Ветрова (Mail.ru Group)
.toster
 
Внутренняя архитектура и устройства соц. сети "Одноклассники"
Внутренняя архитектура и устройства соц. сети "Одноклассники"Внутренняя архитектура и устройства соц. сети "Одноклассники"
Внутренняя архитектура и устройства соц. сети "Одноклассники"
.toster
 
Reusable Code, for good or for awesome!
Reusable Code, for good or for awesome!Reusable Code, for good or for awesome!
Reusable Code, for good or for awesome!
.toster
 
Matthew Eernisse, NodeJs, .toster {webdev}
Matthew Eernisse, NodeJs, .toster {webdev}Matthew Eernisse, NodeJs, .toster {webdev}
Matthew Eernisse, NodeJs, .toster {webdev}
.toster
 
Wild wild web. html5 era
Wild wild web. html5 eraWild wild web. html5 era
Wild wild web. html5 era
.toster
 
Web matrix
Web matrixWeb matrix
Web matrix
.toster
 

Más de .toster (20)

Native look and feel bbui & alicejs
Native look and feel bbui & alicejsNative look and feel bbui & alicejs
Native look and feel bbui & alicejs
 
Sinatra: прошлое, будущее и настоящее
Sinatra: прошлое, будущее и настоящееSinatra: прошлое, будущее и настоящее
Sinatra: прошлое, будущее и настоящее
 
Decyphering Rails 3
Decyphering Rails 3Decyphering Rails 3
Decyphering Rails 3
 
Understanding the Rails web model and scalability options
Understanding the Rails web model and scalability optionsUnderstanding the Rails web model and scalability options
Understanding the Rails web model and scalability options
 
Михаил Черномордиков
Михаил ЧерномордиковМихаил Черномордиков
Михаил Черномордиков
 
Андрей Юношев
Андрей Юношев Андрей Юношев
Андрей Юношев
 
Алексей Тарасенко - Zeptolab
Алексей Тарасенко - ZeptolabАлексей Тарасенко - Zeptolab
Алексей Тарасенко - Zeptolab
 
Maximiliano Firtman - Разработка приложений с помощью PhoneGap
Maximiliano Firtman - Разработка приложений с помощью PhoneGap Maximiliano Firtman - Разработка приложений с помощью PhoneGap
Maximiliano Firtman - Разработка приложений с помощью PhoneGap
 
Вадим Башуров
Вадим БашуровВадим Башуров
Вадим Башуров
 
Вадим Башуров - Как откусить от яблока лимон
Вадим Башуров - Как откусить от яблока лимонВадим Башуров - Как откусить от яблока лимон
Вадим Башуров - Как откусить от яблока лимон
 
Вадим Башуров - Как откусить от яблока лимон
Вадим Башуров - Как откусить от яблока лимонВадим Башуров - Как откусить от яблока лимон
Вадим Башуров - Как откусить от яблока лимон
 
Pablo Villalba -
Pablo Villalba - Pablo Villalba -
Pablo Villalba -
 
Jordi Romero Api for-the-mobile-era
Jordi Romero Api for-the-mobile-eraJordi Romero Api for-the-mobile-era
Jordi Romero Api for-the-mobile-era
 
Презентация Юрия Ветрова (Mail.ru Group)
Презентация Юрия Ветрова (Mail.ru Group)Презентация Юрия Ветрова (Mail.ru Group)
Презентация Юрия Ветрова (Mail.ru Group)
 
Внутренняя архитектура и устройства соц. сети "Одноклассники"
Внутренняя архитектура и устройства соц. сети "Одноклассники"Внутренняя архитектура и устройства соц. сети "Одноклассники"
Внутренняя архитектура и устройства соц. сети "Одноклассники"
 
Reusable Code, for good or for awesome!
Reusable Code, for good or for awesome!Reusable Code, for good or for awesome!
Reusable Code, for good or for awesome!
 
Matthew Eernisse, NodeJs, .toster {webdev}
Matthew Eernisse, NodeJs, .toster {webdev}Matthew Eernisse, NodeJs, .toster {webdev}
Matthew Eernisse, NodeJs, .toster {webdev}
 
Wild wild web. html5 era
Wild wild web. html5 eraWild wild web. html5 era
Wild wild web. html5 era
 
Web matrix
Web matrixWeb matrix
Web matrix
 
NodeJS
NodeJSNodeJS
NodeJS
 

Último

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Último (20)

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 

Практики применения JRuby

  • 3. Short history • 2001 - the first version of JRuby(by Jan Arne Petersen)
  • 4. Short history • 2001 - the first version of JRuby(by Jan Arne Petersen) • 2006 - version 0.9.0(by Charles Nutter, Thomas Enebo, Ola Bini and Nick Siege)
  • 5. Short history • 2001 - the first version of JRuby(by Jan Arne Petersen) • 2006 - version 0.9.0(by Charles Nutter, Thomas Enebo, Ola Bini and Nick Siege) • 2007 - version 1.0(passed all Rails tests)
  • 9. Why JRuby? • Multithreading • JVM • Cross-platform
  • 10. Why JRuby? • Multithreading • JVM • Cross-platform • Just another .jar
  • 11. Why JRuby? • Multithreading • JVM • Cross-platform • Just another .jar • GUI
  • 12. Why JRuby? • Multithreading • JVM • Cross-platform • Just another .jar • GUI • Android
  • 13. JVM
  • 15. JVM • Concurrent threading • Garbage collectors
  • 16. JVM • Concurrent threading • Garbage collectors • JIT compiler
  • 17. JVM • Concurrent threading • Garbage collectors • JIT compiler • invokedynamic(JDK 7)
  • 20. Missing features • Memory footprint • No Kernel#fork
  • 21. Missing features • Memory footprint • No Kernel#fork • No continuations(callcc)
  • 22. Missing features • Memory footprint • No Kernel#fork • No continuations(callcc) • ObjectSpace off by default(-X+O to enable)
  • 23. Missing features • Memory footprint • No Kernel#fork • No continuations(callcc) • ObjectSpace off by default(-X+O to enable) • set_trace_func off by default(--debug to enable)
  • 24. C extensions since JRuby 1.6(still experimental)
  • 25. Easy installing • rvm install jruby • rbenv install jruby-1.6.6 (*) • Download from http://jruby.org
  • 26. Compatibilities Ruby 1.8.7 & 1.9.2 compatible (default 1.8) flag `jruby --1.9` for 1.9.2 compatibility
  • 28. Nailgun (since 1.3.0 version) Nailgun is a client, protocol, and server for running Java programs in the server.
  • 29. Nailgun (since 1.3.0 version) Nailgun is a client, protocol, and server for running Java programs in the server. $ jruby --ng-server & $ jruby --ng -e "puts 1"
  • 30. Multi-VM support many apps in one process
  • 31. Multi-VM support many apps in one process JVM
  • 32. Multi-VM support many apps in one process JRuby JRuby JRuby JRuby JRuby JVM
  • 33. Benchmarks jruby 1.7.0.dev(JDK 6) jruby 1.7.0.dev(JDK 7) invokedynamic=false jruby 1.7.0.dev(JDK 7) ruby 1.9.3-p0
  • 34. Benchmarks jruby 1.7.0.dev(JDK 6) jruby 1.7.0.dev(JDK 7) invokedynamic=false jruby 1.7.0.dev(JDK 7) ruby 1.9.3-p0 4 3 2 1 0 bench/bench_red_black.rb (sec)
  • 35. Benchmarks jruby 1.7.0.dev(JDK 6) jruby 1.7.0.dev(JDK 7) invokedynamic=false jruby 1.7.0.dev(JDK 7) ruby 1.9.3-p0 4 3 2 1 0 bench/bench_red_black.rb (sec)
  • 36. Benchmarks jruby 1.7.0.dev(JDK 6) jruby 1.7.0.dev(JDK 7) invokedynamic=false jruby 1.7.0.dev(JDK 7) ruby 1.9.3-p0 4 3 2 1 0 bench/bench_red_black.rb (sec)
  • 37. Benchmarks jruby 1.7.0.dev(JDK 6) jruby 1.7.0.dev(JDK 7) invokedynamic=false jruby 1.7.0.dev(JDK 7) ruby 1.9.3-p0 4 3 2 1 0 bench/bench_red_black.rb (sec)
  • 38. Benchmarks jruby 1.7.0.dev(JDK 6) jruby 1.7.0.dev(JDK 7) invokedynamic=false jruby 1.7.0.dev(JDK 7) ruby 1.9.3-p0 4 3 2 1 0 bench/bench_red_black.rb (sec)
  • 43. JVM + JRuby • Swing, SWT
  • 44. JVM + JRuby • Swing, SWT • JavaFX
  • 45. JVM + JRuby • Swing, SWT • JavaFX • Spring & Hibernate
  • 46. JVM + JRuby • Swing, SWT • JavaFX • Spring & Hibernate • Scala, Groovy, Jython, Clojure, ...
  • 47. JVM + JRuby Swing
  • 48. JVM + JRuby Swing
  • 51. Java + Ruby • require ‘java’
  • 52. Java + Ruby • require ‘java’ • Java namespace
  • 53. Java + Ruby • require ‘java’ • Java namespace • Snake case(get_some vs getSome)
  • 54. Java + Ruby • require ‘java’ • Java namespace • Snake case(get_some vs getSome) • Ruby-style accessors(length= vs setLength)
  • 55. Java + Ruby • require ‘java’ • Java namespace • Snake case(get_some vs getSome) • Ruby-style accessors(length= vs setLength) • Converting types
  • 56. Java + Ruby • require ‘java’ • Java namespace • Snake case(get_some vs getSome) • Ruby-style accessors(length= vs setLength) • Converting types • Swing IRB(command: jirb_swing)
  • 57. Java bridge Collections
  • 58. Java bridge Collections Java List: java_list[0] java_list << 5 java_list += 7
  • 59. Java bridge Collections Java List: Java Map: java_list[0] java_list[‘key’] java_list << 5 java_list[‘key’] = 5 java_list += 7
  • 60. Java bridge Collections Java List: Java Map: java_list[0] java_list[‘key’] java_list << 5 java_list[‘key’] = 5 java_list += 7 Ruby List: [1, 2, 3].to_java :int [“string”].to_java :string
  • 61. Java bridge Overloading Java: public class Test { public boolean isSome(String arg) {...} public boolean isSome(int arg) {...} public boolean isSome(long arg) {...} public boolean isSome(Object arg) {...} }
  • 62. Java bridge Overloading Ruby: Test.new.java_send :isSome, [Java::long], 1_000 or class Test java_alias :is_some, :isSome, [Java::long] ... end
  • 63. Java bridge Annotations Java: @Bean(scope = Scope.PROTOTYPE) public class Person { ... }
  • 64. Java bridge Annotations Ruby: java_import Bean java_import Scope class Person end Person.add_class_annotation(Bean: { ‘scope’ => Scope.PROTOTYPE }) Person.become_java!
  • 65. Java bridge Interfaces Ruby: class Posts include java.util.Iterator end
  • 66. JRuby compiler Ahead-Of-Time Compilation $ jrubyc <script name>.rb $ java -cp .:/path/to/jruby.jar <script name>
  • 67. JRuby compiler Generate .java classes from .rb $ jrubyc --java <script name>.rb
  • 68. JRuby compiler Ruby: require 'java' class Vec def initialize(x, y) @xcoord = x @ycoord = y end end
  • 69. JRuby compiler Ruby: require 'java' class Vec java_signature 'Vec(double x, double y)' def initialize(x, y) @xcoord = x @ycoord = y end end
  • 70. JRuby compiler Java: import org.jruby.Ruby; import org.jruby.RubyObject; import org.jruby.RubyClass; ... public class Vec extends RubyObject { ... public Vec(double x, double y) { ... } }
  • 72. Rake + Ant Ant tasks like Rake tasks: task :ant_import do ant_import end
  • 73. Buildr http://buildr.apache.org Apache Buildr is a build system for Java-based applications, including support for Scala, Groovy and a growing number of JVM languages and tools.
  • 75. Buildr http://buildr.apache.org • Projects and sub-projects
  • 76. Buildr http://buildr.apache.org • Projects and sub-projects • Compiling, copying and filtering resources, test cases, Javadoc and more
  • 77. Buildr http://buildr.apache.org • Projects and sub-projects • Compiling, copying and filtering resources, test cases, Javadoc and more • Builds what has changed since the last release
  • 78. Buildr http://buildr.apache.org • Projects and sub-projects • Compiling, copying and filtering resources, test cases, Javadoc and more • Builds what has changed since the last release • Support Maven 2.0
  • 79. Buildr http://buildr.apache.org • Projects and sub-projects • Compiling, copying and filtering resources, test cases, Javadoc and more • Builds what has changed since the last release • Support Maven 2.0 • Support Ant
  • 80. Buildr http://buildr.apache.org • Projects and sub-projects • Compiling, copying and filtering resources, test cases, Javadoc and more • Builds what has changed since the last release • Support Maven 2.0 • Support Ant • Buildr is Ruby all the way down
  • 81. Buildr http://buildr.apache.org buildfile: repositories.remote "http://repo.typesafe.com/typesafe/releases/" desc "The Springmongodb project" define "SpringMongoDB" do project.version = "0.1" project.group = "SpringMongoDB" run.with "org.jruby:jruby-complete:jar:1.6.6", "org.mongodb:mongo-java-driver:jar:2.7.2", "org.springframework:spring-core:jar:3.1.0.RELEASE", "org.springframework:spring-context:jar:3.1.0.RELEASE", "org.springframework:spring-beans:jar:3.1.0.RELEASE", 'org.springframework.data:spring-data-commons-core:jar:1.1.0.RELEASE', "org.springframework.data:spring-data-mongodb:jar:1.0.0.RC1" run.using main: ['org.jruby.Main', _(:src, :main, :ruby, "app.rb")] end
  • 82. Rawr http://rawr.rubyforge.org Rawr, a packaging and deployment tool, that allows turns your code into an executable jar, a .exe for Windows, and a .app for OS X.
  • 83. Rawr http://rawr.rubyforge.org $ gem install rawr $ rawr install ... $ rake rawr:jar
  • 85. JRuby-Rack Servlet JRuby-Rack Rack Rack container servlet filter application
  • 87. JRuby servers WEBrick
  • 88. JRuby servers WEBrick Trinidad
  • 89. JRuby servers WEBrick Trinidad TorqueBox
  • 92. TorqueBox http://torquebox.org Installation: jruby -S gem install torquebox-server --pre
  • 93. TorqueBox http://torquebox.org Usage: torquebox deploy ~/Projects/rails_app torquebox run
  • 94. Warbler Warbler is a gem to make a Java jar or war file out of any Ruby, Rails, Merb, or Rack application.
  • 100. Tuning flags • --server - server compiler
  • 101. Tuning flags • --server - server compiler • -Xmx - max heap size
  • 102. Tuning flags • --server - server compiler • -Xmx - max heap size • -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC - new GC(JDK 7)
  • 103. Clouds • Amazon Elastic Beans(http://aws.amazon.com/ elasticbeanstalk/) • Jelastic(http://jelastic.com) • Engine Yard(http://www.engineyard.com) • Google App Engine(http:// appengine.google.com)
  • 107. Bot Hunter • Multithreading • Some logic on Scala
  • 108. Yukihiro Matsumoto: “I would remove the thread and add actors or some other more advanced concurrency features”.
  • 109. Akka http://akka.io/ Simpler Concurrency, Scalability & Fault- tolerance through Actors slidesha.re/akka-scala-days-2010
  • 110. Actor Model of Concurrency slidesha.re/akka-scala-days-2010
  • 111. Actor Model of Concurrency • Implements Message-Passing Concurrency slidesha.re/akka-scala-days-2010
  • 112. Actor Model of Concurrency • Implements Message-Passing Concurrency • Share nothing slidesha.re/akka-scala-days-2010
  • 113. Actor Model of Concurrency • Implements Message-Passing Concurrency • Share nothing • Isolated lightweight process slidesha.re/akka-scala-days-2010
  • 114. Actor Model of Concurrency • Implements Message-Passing Concurrency • Share nothing • Isolated lightweight process • Communicates through messages slidesha.re/akka-scala-days-2010
  • 115. Actor Model of Concurrency • Implements Message-Passing Concurrency • Share nothing • Isolated lightweight process • Communicates through messages • Asynchronous and non-blocking slidesha.re/akka-scala-days-2010
  • 116. Actor Model of Concurrency • Implements Message-Passing Concurrency • Share nothing • Isolated lightweight process • Communicates through messages • Asynchronous and non-blocking • Each actor has a mailbox(message queue) slidesha.re/akka-scala-days-2010
  • 117. Two different models slidesha.re/akka-scala-days-2010
  • 118. Two different models • Thread-based slidesha.re/akka-scala-days-2010
  • 119. Two different models • Thread-based • Event-based slidesha.re/akka-scala-days-2010
  • 120. Two different models • Thread-based • Event-based • Very lightweight(~300 bytes per actor) slidesha.re/akka-scala-days-2010
  • 121. Two different models • Thread-based • Event-based • Very lightweight(~300 bytes per actor) • Can easily create millions on a single workstation slidesha.re/akka-scala-days-2010
  • 122. Example slidesha.re/akka-scala-days-2010
  • 123. Server code class HelloWorldActor extends UntypedActor { public void onReceive(Object msg) { getContext().tryReply(msg + " World"); } } remote().start("localhost", 2552).register( "hello-service", actorOf(HelloWorldActor.class)); slidesha.re/akka-scala-days-2010
  • 124. Client code actor = Actors.remote.actorFor( "hello-service", "localhost", 2552) res = actor.ask("Hello").get slidesha.re/akka-scala-days-2010
  • 127. Groovy

Notas del editor

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n
  48. \n
  49. \n
  50. \n
  51. \n
  52. \n
  53. \n
  54. \n
  55. \n
  56. \n
  57. \n
  58. \n
  59. \n
  60. \n
  61. \n
  62. \n
  63. \n
  64. \n
  65. \n
  66. \n
  67. \n
  68. \n
  69. \n
  70. \n
  71. \n
  72. \n
  73. \n
  74. \n
  75. \n
  76. \n
  77. \n
  78. \n
  79. \n
  80. \n
  81. \n
  82. \n
  83. \n
  84. \n
  85. \n
  86. \n
  87. \n
  88. \n
  89. \n
  90. \n
  91. \n
  92. \n
  93. \n
  94. \n
  95. \n
  96. \n
  97. \n
  98. \n
  99. \n
  100. \n
  101. \n
  102. \n
  103. \n
  104. \n
  105. \n
  106. \n
  107. \n
  108. \n
  109. \n
  110. \n
  111. \n
  112. \n
  113. \n
  114. \n
  115. \n