SlideShare une entreprise Scribd logo
1  sur  21
Télécharger pour lire hors ligne
Java vs Ruby : a quick and fair comparison
      About the pros and cons of two popular programming languages



                                                          Jean-Baptiste Escoyez




Thursday 19 February 2009                                                         1
Java vs Ruby : a quick and unfair comparison
      About the elegance of Ruby
      About the performance of Java
      And how they can live together

                                        Jean-Baptiste Escoyez




Thursday 19 February 2009                                       2
Ruby is interpreted, Java is compiled (before being interpreted)

       >ruby my_program.rb                                                   >javac MyProgram.java
                                                                             >java MyProgram


      • Code can be loaded at runtime


      • Code is easily accessible


      • Difficult to ship closed-source software


      • Speed performance issues




      Java vs Ruby : a quick and unfair comparison - Jean-Baptiste Escoyez

Thursday 19 February 2009                                                                            3
Ruby use dynamic typing

      • Values have type, variables not                                      def len(list)
                                                                               x=0
                                                                               list.each do |element|
      • Decrease language complexity                                             x += 1
                                                                               end
                                                                             end
            - No type declaration
                                                                             public static int len(List list)
            - No type casting                                                {
                                                                               int x = 0;
                                                                               Iterator listIterator =
      • Increase flexibility                                                    list.iterator();
                                                                               while(listIterator.hasNext()){
                                                                                 x += 1;
      • Errors appears at run-time                                             }
                                                                             }




      Java vs Ruby : a quick and unfair comparison - Jean-Baptiste Escoyez

Thursday 19 February 2009                                                                                       4
Ruby syntax is terse

      • Example 1 : The empty program




      • Java




      • Ruby




      Java vs Ruby : a quick and unfair comparison - Jean-Baptiste Escoyez

Thursday 19 February 2009                                                    5
Ruby syntax is terse

      • Example 1 : The empty program




                                Class Test {
      • Java                      public static void main(String[] args){}
                                }



      • Ruby




      Java vs Ruby : a quick and unfair comparison - Jean-Baptiste Escoyez

Thursday 19 February 2009                                                    5
Ruby syntax is terse
      • Example 2 : Basic getters and setters

                            Class Circle
      • Java                  private Coordinate center, float radius;

                                public void setCenter(Coordinate center){
                                  this.center = center;
                                }

                                public Coordinate getCenter(){
                                  return center;
                                }

                                public void setRadius(float radius){
                                  this.radius = radius;
                                }

                                public Coordinate getRadius(){
                                  return radius;
                                }
                            }

                            class Circle
      • Ruby                  attr_accessor :center, :radius
                            end

      Java vs Ruby : a quick and unfair comparison - Jean-Baptiste Escoyez

Thursday 19 February 2009                                                    6
Ruby syntax is terse
      • Example 3 : Playing with lists


      • Java                List<String> languages = new LinkedList<String>();
                            languages.add(quot;Javaquot;);
                            languages.add(quot;Rubyquot;);
                            languages.add(quot;Pythonquot;);
                            languages.add(quot;Perlquot;);

      • Ruby                stuff = []
                            stuff << quot;Javaquot;, quot;Rubyquot;, quot;Pythonquot;


                            stuff = [quot;Javaquot;, quot;Rubyquot;, quot;Pythonquot;]


                            stuff = %w(Java Ruby Python)




      Java vs Ruby : a quick and unfair comparison - Jean-Baptiste Escoyez

Thursday 19 February 2009                                                        7
Everything is an object (really everything!)
       >3.times             { puts          quot;Hello FOSDEM !quot; }
       => Hello             FOSDEM          !
       => Hello             FOSDEM          !
       => Hello             FOSDEM          !


       >self.class
       => Object

       >1.class
       => Fixnum




      Java vs Ruby : a quick and unfair comparison - Jean-Baptiste Escoyez

Thursday 19 February 2009                                                    8
Core classes can be extended easily

      • A program which makes you crazy

         class Fixnum
           def +(i)
             self - i
           end
         end

         >1 + 1
         => 0




      Java vs Ruby : a quick and unfair comparison - Jean-Baptiste Escoyez

Thursday 19 February 2009                                                    9
require ‘activesupport’

      • Java                   if ( 1 % 2 == 1 ) System.err.println(quot;Odd!quot;)
                               => Odd!


      • Ruby                   if 11.odd?; print quot;Odd!
                               => Odd!

      • Java                   System.out.println(quot;Running time: quot; + 
                                        (3600 + 15 * 60 + 10) + quot;secondsquot;);

      • Ruby                   puts quot;Running time: 
                               #{1.hour + 15.minutes + 10.seconds} secondsquot;



      Java vs Ruby : a quick and unfair comparison - Jean-Baptiste Escoyez

Thursday 19 February 2009                                                     10
Blocks


              >find_integer([quot;aquot;,1, 4, 2,quot;9quot;,quot;cquot;]){|e| e.odd?}
              => 1



               >def find_integer(array)
               > for element in array
               >    if element.is_a?(Integer) && yield element
               >      return element
               >    end
               > end
               >end




      Java vs Ruby : a quick and unfair comparison - Jean-Baptiste Escoyez

Thursday 19 February 2009                                                    11
Tidbits of metaprogramming

      • Execution of given code

                             >eval(quot;puts 'Hi FOSDEM'quot;)
                             => Hi FOSDEM

      • Class extension

                             >speaker = Class.new
                             >speaker.class_eval do
                             > def hello_fosdem
                             >    puts “Hello FOSDEM!”
                             > end
                             >end
                             >jean_baptiste = speaker.new
                             >jean_baptiste.hello_fosdem
                             => “Hello FOSDEM!”

      Java vs Ruby : a quick and unfair comparison - Jean-Baptiste Escoyez

Thursday 19 February 2009                                                    12
Going a bit further

      • Defining methods

                            >people = [quot;stevequot;, quot;aurelienquot;]
                            >speaker = Class.new
                            >speaker.class_eval do
                            > people.each do |person|
                            >    define_method(quot;hello_#{person}quot;){
                            >      puts quot;Hello #{person}quot;
                            >    }
                            > end
                            >end
                            >jean_baptiste = speaker.new
                            >jean_baptiste.methods - Object.methods
                            => [quot;hello_stevequot;, quot;hello_aurelienquot;]
                            >jean_baptiste.hello_steve
                            => “Hello steve”

      Java vs Ruby : a quick and unfair comparison - Jean-Baptiste Escoyez

Thursday 19 February 2009                                                    13
Summary

      • Ruby is elegant

      • Ruby is meaningful

      • Ruby is flexible

      • Ruby is easily extensible

      • Ruby is terse




      Java vs Ruby : a quick and unfair comparison - Jean-Baptiste Escoyez

Thursday 19 February 2009                                                    14
Summary

      • Ruby is elegant

      • Ruby is meaningful

      • Ruby is flexible

      • Ruby is easily extensible

      • Ruby is terse

                                                      Is that all ???
                                                     What about Java?
      Java vs Ruby : a quick and unfair comparison - Jean-Baptiste Escoyez

Thursday 19 February 2009                                                    14
Java win on performance field




                            Source : http://shootout.alioth.debian.org/u32q/benchmark.php
      Java vs Ruby : a quick and unfair comparison - Jean-Baptiste Escoyez

Thursday 19 February 2009                                                                   15
On a business point of view

      • Java is a well-known technology

      • Lots of developments have been made with it

      • Easy to find experts

      • Still not that much available Ruby developers

      • Opensource fear




      Java vs Ruby : a quick and unfair comparison - Jean-Baptiste Escoyez

Thursday 19 February 2009                                                    16
Solution: make them collaborate !




      •JRuby : Demo



      Java vs Ruby : a quick and unfair comparison - Jean-Baptiste Escoyez

Thursday 19 February 2009                                                    17
Conclusion

      • Languages wars do not make sens

      • Ruby is great for its terseness, readability and flexibility

      • Java is great for its performances

      • JRuby makes them talk together

      • Ruby + Java is a great combo




      Java vs Ruby : a quick and unfair comparison - Jean-Baptiste Escoyez

Thursday 19 February 2009                                                    18
Thank you!
      Questions?


                            References :
                            http://www.rubyrailways.com/sometimes-less-is-more/
                            http://www.javaworld.com/javaworld/jw-07-2006/jw-0717-ruby.html
                            http://shootout.alioth.debian.org/u32q/benchmark.php?test=all&lang=java&lang2=ruby
                            http://ola-bini.blogspot.com/2008/04/pragmatic-static-typing.html




Thursday 19 February 2009                                                                                        19

Contenu connexe

Tendances

Automatically generating-json-from-java-objects-java-objects268
Automatically generating-json-from-java-objects-java-objects268Automatically generating-json-from-java-objects-java-objects268
Automatically generating-json-from-java-objects-java-objects268Ramamohan Chokkam
 
An Introduction to Scala for Java Developers
An Introduction to Scala for Java DevelopersAn Introduction to Scala for Java Developers
An Introduction to Scala for Java DevelopersMiles Sabin
 
Introduction to Ruby Programming Language
Introduction to Ruby Programming LanguageIntroduction to Ruby Programming Language
Introduction to Ruby Programming LanguageNicolò Calcavecchia
 
Clojure - An Introduction for Java Programmers
Clojure - An Introduction for Java ProgrammersClojure - An Introduction for Java Programmers
Clojure - An Introduction for Java Programmerselliando dias
 
Clojure - An Introduction for Lisp Programmers
Clojure - An Introduction for Lisp ProgrammersClojure - An Introduction for Lisp Programmers
Clojure - An Introduction for Lisp Programmerselliando dias
 
2008 Sccc Inheritance
2008 Sccc Inheritance2008 Sccc Inheritance
2008 Sccc Inheritancebergel
 
Java Course 3: OOP
Java Course 3: OOPJava Course 3: OOP
Java Course 3: OOPAnton Keks
 
Clojure talk at Münster JUG
Clojure talk at Münster JUGClojure talk at Münster JUG
Clojure talk at Münster JUGAlex Ott
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to ScalaBrian Hsu
 
The ruby programming language
The ruby programming languageThe ruby programming language
The ruby programming languagepraveen0202
 
Java Course 4: Exceptions & Collections
Java Course 4: Exceptions & CollectionsJava Course 4: Exceptions & Collections
Java Course 4: Exceptions & CollectionsAnton Keks
 
Introduction To Grails
Introduction To GrailsIntroduction To Grails
Introduction To GrailsEric Berry
 
A Brief, but Dense, Intro to Scala
A Brief, but Dense, Intro to ScalaA Brief, but Dense, Intro to Scala
A Brief, but Dense, Intro to ScalaDerek Chen-Becker
 
Java Course 7: Text processing, Charsets & Encodings
Java Course 7: Text processing, Charsets & EncodingsJava Course 7: Text processing, Charsets & Encodings
Java Course 7: Text processing, Charsets & EncodingsAnton Keks
 
Java Course 2: Basics
Java Course 2: BasicsJava Course 2: Basics
Java Course 2: BasicsAnton Keks
 
Introduction to Clojure
Introduction to ClojureIntroduction to Clojure
Introduction to ClojureRenzo Borgatti
 
Terence Barr - jdk7+8 - 24mai2011
Terence Barr - jdk7+8 - 24mai2011Terence Barr - jdk7+8 - 24mai2011
Terence Barr - jdk7+8 - 24mai2011Agora Group
 
Modularization of Legacy Features by Relocation and Reconceptualization: How ...
Modularization of Legacy Features by Relocation and Reconceptualization: How ...Modularization of Legacy Features by Relocation and Reconceptualization: How ...
Modularization of Legacy Features by Relocation and Reconceptualization: How ...Andrzej Olszak
 

Tendances (20)

Automatically generating-json-from-java-objects-java-objects268
Automatically generating-json-from-java-objects-java-objects268Automatically generating-json-from-java-objects-java-objects268
Automatically generating-json-from-java-objects-java-objects268
 
An Introduction to Scala for Java Developers
An Introduction to Scala for Java DevelopersAn Introduction to Scala for Java Developers
An Introduction to Scala for Java Developers
 
Introduction to Ruby Programming Language
Introduction to Ruby Programming LanguageIntroduction to Ruby Programming Language
Introduction to Ruby Programming Language
 
Clojure - An Introduction for Java Programmers
Clojure - An Introduction for Java ProgrammersClojure - An Introduction for Java Programmers
Clojure - An Introduction for Java Programmers
 
Clojure - An Introduction for Lisp Programmers
Clojure - An Introduction for Lisp ProgrammersClojure - An Introduction for Lisp Programmers
Clojure - An Introduction for Lisp Programmers
 
2008 Sccc Inheritance
2008 Sccc Inheritance2008 Sccc Inheritance
2008 Sccc Inheritance
 
Java Course 3: OOP
Java Course 3: OOPJava Course 3: OOP
Java Course 3: OOP
 
Clojure talk at Münster JUG
Clojure talk at Münster JUGClojure talk at Münster JUG
Clojure talk at Münster JUG
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to Scala
 
How big is your data
How big is your dataHow big is your data
How big is your data
 
The ruby programming language
The ruby programming languageThe ruby programming language
The ruby programming language
 
Java Course 4: Exceptions & Collections
Java Course 4: Exceptions & CollectionsJava Course 4: Exceptions & Collections
Java Course 4: Exceptions & Collections
 
Introduction To Grails
Introduction To GrailsIntroduction To Grails
Introduction To Grails
 
A Brief, but Dense, Intro to Scala
A Brief, but Dense, Intro to ScalaA Brief, but Dense, Intro to Scala
A Brief, but Dense, Intro to Scala
 
Java Course 7: Text processing, Charsets & Encodings
Java Course 7: Text processing, Charsets & EncodingsJava Course 7: Text processing, Charsets & Encodings
Java Course 7: Text processing, Charsets & Encodings
 
Java Course 2: Basics
Java Course 2: BasicsJava Course 2: Basics
Java Course 2: Basics
 
Introduction to Clojure
Introduction to ClojureIntroduction to Clojure
Introduction to Clojure
 
Terence Barr - jdk7+8 - 24mai2011
Terence Barr - jdk7+8 - 24mai2011Terence Barr - jdk7+8 - 24mai2011
Terence Barr - jdk7+8 - 24mai2011
 
Core java
Core javaCore java
Core java
 
Modularization of Legacy Features by Relocation and Reconceptualization: How ...
Modularization of Legacy Features by Relocation and Reconceptualization: How ...Modularization of Legacy Features by Relocation and Reconceptualization: How ...
Modularization of Legacy Features by Relocation and Reconceptualization: How ...
 

En vedette

Ruby For Java Programmers
Ruby For Java ProgrammersRuby For Java Programmers
Ruby For Java ProgrammersMike Bowler
 
PHP, Java EE & .NET Comparison
PHP, Java EE & .NET ComparisonPHP, Java EE & .NET Comparison
PHP, Java EE & .NET ComparisonHaim Michael
 
Difference between Java and c#
Difference between Java and c#Difference between Java and c#
Difference between Java and c#Sagar Pednekar
 
MacRuby - When objective-c and Ruby meet
MacRuby - When objective-c and Ruby meetMacRuby - When objective-c and Ruby meet
MacRuby - When objective-c and Ruby meetMatt Aimonetti
 
Understanding Typing. Understanding Ruby.
Understanding Typing. Understanding Ruby.Understanding Typing. Understanding Ruby.
Understanding Typing. Understanding Ruby.Justin Lin
 
BDD. Gherkin+Ruby или автотесты для гуманитариев
BDD. Gherkin+Ruby или автотесты для гуманитариевBDD. Gherkin+Ruby или автотесты для гуманитариев
BDD. Gherkin+Ruby или автотесты для гуманитариевSQALab
 
Ошибка выживших
Ошибка выжившихОшибка выживших
Ошибка выжившихSQALab
 
Criação de uma equipe de QAs, do Waterfall ao Agile
Criação de uma equipe de QAs, do Waterfall ao AgileCriação de uma equipe de QAs, do Waterfall ao Agile
Criação de uma equipe de QAs, do Waterfall ao AgileRobson Agapito Correa
 
QA Automation Battle: Java vs Python vs Ruby [09.04.2015]
QA Automation Battle: Java vs Python vs Ruby [09.04.2015]QA Automation Battle: Java vs Python vs Ruby [09.04.2015]
QA Automation Battle: Java vs Python vs Ruby [09.04.2015]GoIT
 
Automated Testing with Ruby
Automated Testing with RubyAutomated Testing with Ruby
Automated Testing with RubyKeith Pitty
 
Jruby, o melhor de 2 mundos (MacGyver + ChuckNorris)
Jruby, o melhor de 2 mundos (MacGyver + ChuckNorris)Jruby, o melhor de 2 mundos (MacGyver + ChuckNorris)
Jruby, o melhor de 2 mundos (MacGyver + ChuckNorris)Marcio Sfalsin
 
[38º GURU SP] Automação de Testes Web em Ruby com Cucumber e Webdriver
[38º GURU SP] Automação de Testes Web em Ruby com Cucumber e Webdriver[38º GURU SP] Automação de Testes Web em Ruby com Cucumber e Webdriver
[38º GURU SP] Automação de Testes Web em Ruby com Cucumber e WebdriverJúlio de Lima
 
Java vs .net
Java vs .netJava vs .net
Java vs .netTech_MX
 

En vedette (20)

MacRuby, an introduction
MacRuby, an introductionMacRuby, an introduction
MacRuby, an introduction
 
Ruby For Java Programmers
Ruby For Java ProgrammersRuby For Java Programmers
Ruby For Java Programmers
 
Java vs. Ruby
Java vs. RubyJava vs. Ruby
Java vs. Ruby
 
PHP, Java EE & .NET Comparison
PHP, Java EE & .NET ComparisonPHP, Java EE & .NET Comparison
PHP, Java EE & .NET Comparison
 
Difference between Java and c#
Difference between Java and c#Difference between Java and c#
Difference between Java and c#
 
MacRuby - When objective-c and Ruby meet
MacRuby - When objective-c and Ruby meetMacRuby - When objective-c and Ruby meet
MacRuby - When objective-c and Ruby meet
 
Understanding Typing. Understanding Ruby.
Understanding Typing. Understanding Ruby.Understanding Typing. Understanding Ruby.
Understanding Typing. Understanding Ruby.
 
BDD. Gherkin+Ruby или автотесты для гуманитариев
BDD. Gherkin+Ruby или автотесты для гуманитариевBDD. Gherkin+Ruby или автотесты для гуманитариев
BDD. Gherkin+Ruby или автотесты для гуманитариев
 
Ошибка выживших
Ошибка выжившихОшибка выживших
Ошибка выживших
 
Ruby 1.9
Ruby 1.9Ruby 1.9
Ruby 1.9
 
Seu site voando
Seu site voandoSeu site voando
Seu site voando
 
Apresentação sobre JRuby
Apresentação sobre JRubyApresentação sobre JRuby
Apresentação sobre JRuby
 
Criação de uma equipe de QAs, do Waterfall ao Agile
Criação de uma equipe de QAs, do Waterfall ao AgileCriação de uma equipe de QAs, do Waterfall ao Agile
Criação de uma equipe de QAs, do Waterfall ao Agile
 
QA Automation Battle: Java vs Python vs Ruby [09.04.2015]
QA Automation Battle: Java vs Python vs Ruby [09.04.2015]QA Automation Battle: Java vs Python vs Ruby [09.04.2015]
QA Automation Battle: Java vs Python vs Ruby [09.04.2015]
 
PHP versus Java
PHP versus JavaPHP versus Java
PHP versus Java
 
Automated Testing with Ruby
Automated Testing with RubyAutomated Testing with Ruby
Automated Testing with Ruby
 
Jruby, o melhor de 2 mundos (MacGyver + ChuckNorris)
Jruby, o melhor de 2 mundos (MacGyver + ChuckNorris)Jruby, o melhor de 2 mundos (MacGyver + ChuckNorris)
Jruby, o melhor de 2 mundos (MacGyver + ChuckNorris)
 
Scala vs Ruby
Scala vs RubyScala vs Ruby
Scala vs Ruby
 
[38º GURU SP] Automação de Testes Web em Ruby com Cucumber e Webdriver
[38º GURU SP] Automação de Testes Web em Ruby com Cucumber e Webdriver[38º GURU SP] Automação de Testes Web em Ruby com Cucumber e Webdriver
[38º GURU SP] Automação de Testes Web em Ruby com Cucumber e Webdriver
 
Java vs .net
Java vs .netJava vs .net
Java vs .net
 

Similaire à Ruby vs Java

Ola Bini J Ruby Power On The Jvm
Ola Bini J Ruby Power On The JvmOla Bini J Ruby Power On The Jvm
Ola Bini J Ruby Power On The Jvmdeimos
 
J Ruby Power On The Jvm
J Ruby Power On The JvmJ Ruby Power On The Jvm
J Ruby Power On The JvmQConLondon2008
 
Ruby Programming Introduction
Ruby Programming IntroductionRuby Programming Introduction
Ruby Programming IntroductionAnthony Brown
 
JRuby - Java version of Ruby
JRuby - Java version of RubyJRuby - Java version of Ruby
JRuby - Java version of RubyUday Bhaskar
 
JRoR Deploying Rails on JRuby
JRoR Deploying Rails on JRubyJRoR Deploying Rails on JRuby
JRoR Deploying Rails on JRubyelliando dias
 
Using Java from Ruby with JRuby IRB
Using Java from Ruby with JRuby IRBUsing Java from Ruby with JRuby IRB
Using Java from Ruby with JRuby IRBHiro Asari
 
Real-world polyglot programming on the JVM - Ben Summers (ONEIS)
Real-world polyglot programming on the JVM  - Ben Summers (ONEIS)Real-world polyglot programming on the JVM  - Ben Summers (ONEIS)
Real-world polyglot programming on the JVM - Ben Summers (ONEIS)jaxLondonConference
 
Ruby for C#-ers (ScanDevConf 2010)
Ruby for C#-ers (ScanDevConf 2010)Ruby for C#-ers (ScanDevConf 2010)
Ruby for C#-ers (ScanDevConf 2010)Thomas Lundström
 
javascript teach
javascript teachjavascript teach
javascript teachguest3732fa
 
JSBootcamp_White
JSBootcamp_WhiteJSBootcamp_White
JSBootcamp_Whiteguest3732fa
 
Minicurso Ruby e Rails
Minicurso Ruby e RailsMinicurso Ruby e Rails
Minicurso Ruby e RailsSEA Tecnologia
 
Bitter Java, Sweeten with JRuby
Bitter Java, Sweeten with JRubyBitter Java, Sweeten with JRuby
Bitter Java, Sweeten with JRubyBrian Sam-Bodden
 
The Enterprise Strikes Back
The Enterprise Strikes BackThe Enterprise Strikes Back
The Enterprise Strikes BackBurke Libbey
 
J Ruby Whirlwind Tour
J Ruby Whirlwind TourJ Ruby Whirlwind Tour
J Ruby Whirlwind Touroscon2007
 
Hacking with ruby2ruby
Hacking with ruby2rubyHacking with ruby2ruby
Hacking with ruby2rubyMarc Chung
 
JRuby - Enterprise 2.0
JRuby - Enterprise 2.0JRuby - Enterprise 2.0
JRuby - Enterprise 2.0Jan Sifra
 

Similaire à Ruby vs Java (20)

Ola Bini J Ruby Power On The Jvm
Ola Bini J Ruby Power On The JvmOla Bini J Ruby Power On The Jvm
Ola Bini J Ruby Power On The Jvm
 
J Ruby Power On The Jvm
J Ruby Power On The JvmJ Ruby Power On The Jvm
J Ruby Power On The Jvm
 
Ruby Programming Introduction
Ruby Programming IntroductionRuby Programming Introduction
Ruby Programming Introduction
 
JRuby - Java version of Ruby
JRuby - Java version of RubyJRuby - Java version of Ruby
JRuby - Java version of Ruby
 
JRoR Deploying Rails on JRuby
JRoR Deploying Rails on JRubyJRoR Deploying Rails on JRuby
JRoR Deploying Rails on JRuby
 
BeJUG JavaFx In Practice
BeJUG JavaFx In PracticeBeJUG JavaFx In Practice
BeJUG JavaFx In Practice
 
Using Java from Ruby with JRuby IRB
Using Java from Ruby with JRuby IRBUsing Java from Ruby with JRuby IRB
Using Java from Ruby with JRuby IRB
 
JRuby Basics
JRuby BasicsJRuby Basics
JRuby Basics
 
Real-world polyglot programming on the JVM - Ben Summers (ONEIS)
Real-world polyglot programming on the JVM  - Ben Summers (ONEIS)Real-world polyglot programming on the JVM  - Ben Summers (ONEIS)
Real-world polyglot programming on the JVM - Ben Summers (ONEIS)
 
Ruby for C#-ers (ScanDevConf 2010)
Ruby for C#-ers (ScanDevConf 2010)Ruby for C#-ers (ScanDevConf 2010)
Ruby for C#-ers (ScanDevConf 2010)
 
javascript teach
javascript teachjavascript teach
javascript teach
 
JSBootcamp_White
JSBootcamp_WhiteJSBootcamp_White
JSBootcamp_White
 
Minicurso Ruby e Rails
Minicurso Ruby e RailsMinicurso Ruby e Rails
Minicurso Ruby e Rails
 
Intro to J Ruby
Intro to J RubyIntro to J Ruby
Intro to J Ruby
 
Bitter Java, Sweeten with JRuby
Bitter Java, Sweeten with JRubyBitter Java, Sweeten with JRuby
Bitter Java, Sweeten with JRuby
 
The Enterprise Strikes Back
The Enterprise Strikes BackThe Enterprise Strikes Back
The Enterprise Strikes Back
 
Ruby
RubyRuby
Ruby
 
J Ruby Whirlwind Tour
J Ruby Whirlwind TourJ Ruby Whirlwind Tour
J Ruby Whirlwind Tour
 
Hacking with ruby2ruby
Hacking with ruby2rubyHacking with ruby2ruby
Hacking with ruby2ruby
 
JRuby - Enterprise 2.0
JRuby - Enterprise 2.0JRuby - Enterprise 2.0
JRuby - Enterprise 2.0
 

Dernier

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
 
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
 
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
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
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
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
"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
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
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
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
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
 
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
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 

Dernier (20)

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
 
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!
 
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
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
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
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
"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
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
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
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
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
 
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
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 

Ruby vs Java

  • 1. Java vs Ruby : a quick and fair comparison About the pros and cons of two popular programming languages Jean-Baptiste Escoyez Thursday 19 February 2009 1
  • 2. Java vs Ruby : a quick and unfair comparison About the elegance of Ruby About the performance of Java And how they can live together Jean-Baptiste Escoyez Thursday 19 February 2009 2
  • 3. Ruby is interpreted, Java is compiled (before being interpreted) >ruby my_program.rb >javac MyProgram.java >java MyProgram • Code can be loaded at runtime • Code is easily accessible • Difficult to ship closed-source software • Speed performance issues Java vs Ruby : a quick and unfair comparison - Jean-Baptiste Escoyez Thursday 19 February 2009 3
  • 4. Ruby use dynamic typing • Values have type, variables not def len(list) x=0 list.each do |element| • Decrease language complexity x += 1 end end - No type declaration public static int len(List list) - No type casting { int x = 0; Iterator listIterator = • Increase flexibility list.iterator(); while(listIterator.hasNext()){ x += 1; • Errors appears at run-time } } Java vs Ruby : a quick and unfair comparison - Jean-Baptiste Escoyez Thursday 19 February 2009 4
  • 5. Ruby syntax is terse • Example 1 : The empty program • Java • Ruby Java vs Ruby : a quick and unfair comparison - Jean-Baptiste Escoyez Thursday 19 February 2009 5
  • 6. Ruby syntax is terse • Example 1 : The empty program Class Test { • Java public static void main(String[] args){} } • Ruby Java vs Ruby : a quick and unfair comparison - Jean-Baptiste Escoyez Thursday 19 February 2009 5
  • 7. Ruby syntax is terse • Example 2 : Basic getters and setters Class Circle • Java private Coordinate center, float radius; public void setCenter(Coordinate center){ this.center = center; } public Coordinate getCenter(){ return center; } public void setRadius(float radius){ this.radius = radius; } public Coordinate getRadius(){ return radius; } } class Circle • Ruby attr_accessor :center, :radius end Java vs Ruby : a quick and unfair comparison - Jean-Baptiste Escoyez Thursday 19 February 2009 6
  • 8. Ruby syntax is terse • Example 3 : Playing with lists • Java List<String> languages = new LinkedList<String>(); languages.add(quot;Javaquot;); languages.add(quot;Rubyquot;); languages.add(quot;Pythonquot;); languages.add(quot;Perlquot;); • Ruby stuff = [] stuff << quot;Javaquot;, quot;Rubyquot;, quot;Pythonquot; stuff = [quot;Javaquot;, quot;Rubyquot;, quot;Pythonquot;] stuff = %w(Java Ruby Python) Java vs Ruby : a quick and unfair comparison - Jean-Baptiste Escoyez Thursday 19 February 2009 7
  • 9. Everything is an object (really everything!) >3.times { puts quot;Hello FOSDEM !quot; } => Hello FOSDEM ! => Hello FOSDEM ! => Hello FOSDEM ! >self.class => Object >1.class => Fixnum Java vs Ruby : a quick and unfair comparison - Jean-Baptiste Escoyez Thursday 19 February 2009 8
  • 10. Core classes can be extended easily • A program which makes you crazy class Fixnum def +(i) self - i end end >1 + 1 => 0 Java vs Ruby : a quick and unfair comparison - Jean-Baptiste Escoyez Thursday 19 February 2009 9
  • 11. require ‘activesupport’ • Java if ( 1 % 2 == 1 ) System.err.println(quot;Odd!quot;) => Odd! • Ruby if 11.odd?; print quot;Odd! => Odd! • Java System.out.println(quot;Running time: quot; + (3600 + 15 * 60 + 10) + quot;secondsquot;); • Ruby puts quot;Running time: #{1.hour + 15.minutes + 10.seconds} secondsquot; Java vs Ruby : a quick and unfair comparison - Jean-Baptiste Escoyez Thursday 19 February 2009 10
  • 12. Blocks >find_integer([quot;aquot;,1, 4, 2,quot;9quot;,quot;cquot;]){|e| e.odd?} => 1 >def find_integer(array) > for element in array > if element.is_a?(Integer) && yield element > return element > end > end >end Java vs Ruby : a quick and unfair comparison - Jean-Baptiste Escoyez Thursday 19 February 2009 11
  • 13. Tidbits of metaprogramming • Execution of given code >eval(quot;puts 'Hi FOSDEM'quot;) => Hi FOSDEM • Class extension >speaker = Class.new >speaker.class_eval do > def hello_fosdem > puts “Hello FOSDEM!” > end >end >jean_baptiste = speaker.new >jean_baptiste.hello_fosdem => “Hello FOSDEM!” Java vs Ruby : a quick and unfair comparison - Jean-Baptiste Escoyez Thursday 19 February 2009 12
  • 14. Going a bit further • Defining methods >people = [quot;stevequot;, quot;aurelienquot;] >speaker = Class.new >speaker.class_eval do > people.each do |person| > define_method(quot;hello_#{person}quot;){ > puts quot;Hello #{person}quot; > } > end >end >jean_baptiste = speaker.new >jean_baptiste.methods - Object.methods => [quot;hello_stevequot;, quot;hello_aurelienquot;] >jean_baptiste.hello_steve => “Hello steve” Java vs Ruby : a quick and unfair comparison - Jean-Baptiste Escoyez Thursday 19 February 2009 13
  • 15. Summary • Ruby is elegant • Ruby is meaningful • Ruby is flexible • Ruby is easily extensible • Ruby is terse Java vs Ruby : a quick and unfair comparison - Jean-Baptiste Escoyez Thursday 19 February 2009 14
  • 16. Summary • Ruby is elegant • Ruby is meaningful • Ruby is flexible • Ruby is easily extensible • Ruby is terse Is that all ??? What about Java? Java vs Ruby : a quick and unfair comparison - Jean-Baptiste Escoyez Thursday 19 February 2009 14
  • 17. Java win on performance field Source : http://shootout.alioth.debian.org/u32q/benchmark.php Java vs Ruby : a quick and unfair comparison - Jean-Baptiste Escoyez Thursday 19 February 2009 15
  • 18. On a business point of view • Java is a well-known technology • Lots of developments have been made with it • Easy to find experts • Still not that much available Ruby developers • Opensource fear Java vs Ruby : a quick and unfair comparison - Jean-Baptiste Escoyez Thursday 19 February 2009 16
  • 19. Solution: make them collaborate ! •JRuby : Demo Java vs Ruby : a quick and unfair comparison - Jean-Baptiste Escoyez Thursday 19 February 2009 17
  • 20. Conclusion • Languages wars do not make sens • Ruby is great for its terseness, readability and flexibility • Java is great for its performances • JRuby makes them talk together • Ruby + Java is a great combo Java vs Ruby : a quick and unfair comparison - Jean-Baptiste Escoyez Thursday 19 February 2009 18
  • 21. Thank you! Questions? References : http://www.rubyrailways.com/sometimes-less-is-more/ http://www.javaworld.com/javaworld/jw-07-2006/jw-0717-ruby.html http://shootout.alioth.debian.org/u32q/benchmark.php?test=all&lang=java&lang2=ruby http://ola-bini.blogspot.com/2008/04/pragmatic-static-typing.html Thursday 19 February 2009 19