SlideShare a Scribd company logo
1 of 21
Download to read offline
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

More Related Content

What's hot

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
 

What's hot (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 ...
 

Viewers also liked

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
 

Viewers also liked (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
 

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

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

Recently uploaded

Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
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 2024Rafal Los
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 

Recently uploaded (20)

Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
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
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 

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