Ruby vs Java
Upcoming SlideShare
Loading in...5
×
 

Ruby vs Java

on

  • 54,026 views

A quick and unfair comparison of Ruby and Java.

A quick and unfair comparison of Ruby and Java.

Statistics

Views

Total Views
54,026
Views on SlideShare
51,759
Embed Views
2,267

Actions

Likes
18
Downloads
444
Comments
4

40 Embeds 2,267

http://automated-testing.info 668
http://carlosdamian.blogspot.com 485
http://localhost 284
http://carlosdamian.blogspot.com.es 198
http://www.slideshare.net 167
http://carlosdamian.blogspot.mx 72
http://rafalchmiel.github.io 68
http://rafalchmiel.github.com 60
http://www.net4java.com 58
http://carlosdamian.blogspot.com.ar 49
http://autotest.aexchecker.com 43
http://rubylove.info 22
http://milandobrota.tumblr.com 15
http://www.automated-testing.info 13
http://rafalchmiel.com 9
http://r-quadrant.blogspot.com 8
http://www.rubylove.info 8
http://zero.andrisetiawan.info 6
http://macca158.blogspot.de 4
http://macca158.blogspot.com 4
http://paper.li 3
http://www.e-presentations.us 2
http://webcache.googleusercontent.com 2
http://askqtp.blogspot.com 2
http://twitc.com 2
http://www.askqtp.com 1
http://carlosdamian.blogspot.ru 1
http://lurnq.com 1
http://hghltd.yandex.net 1
http://209.85.173.132 1
http://macca158.blogspot.co.uk 1
http://r-quadrant.blogspot.com.au 1
http://translate.googleusercontent.com 1
http://www.lurnq.com 1
http://carlosdamian.blogspot.co.uk 1
http://carlosdamian.blogspot.de 1
http://carlosdamian.blogspot.ch 1
http://carlosdamian.blogspot.in 1
http://carlosdamian.blogspot.com.br 1
http://www.linkedin.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • One of the key advantages of Java is its IDE support, especially large project refactoring and completion. Many of these features are impossible in a dynamically typed language. And not to forget that in a large project you find many errors upfront. So yes, Ruby is more terse but I think in Eclipse or other modern IDEs writing robust software is faster.
    Are you sure you want to
    Your message goes here
    Processing…
  • Slide 4, you can write for (final int i : list) { x++;} without the iterator, so your demonstration is a bit more fair.. ;)
    Are you sure you want to
    Your message goes here
    Processing…
  • No entiendo ingles.... help me please :(
    Are you sure you want to
    Your message goes here
    Processing…
  • The usage of imagery in this presentation is really effective. You've done a fantastic job here friend.
    Sharika
    http://winkhealth.com http://financewink.com
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Ruby vs Java Ruby vs Java Presentation Transcript

  • 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