: 
http://rubylearning.com/
http://rubylearning.com/satishtalim/tutorial.html
http://rubylearning.com/download/downloads.html
http://rubylearning.com/other/certification.html
http://rubylearning.com/blog/
http://rubylearning.com/other/ruby_news.html
http://rubylearning.com/other/testimonials.html
http://rubylearning.com/jobs/ruby_jobs.html
http://rubylearning.com/other/ruby_gurus.html
http://rubylearning.com/satishtalim/services.html
http://rubylearning.com/contact/contact.html
http://rubylearning.com/satishtalim/about.html


Java to Ruby

I come to Ruby from a Java background and the following Similarities and Differences would help you come to terms with Ruby.


Similarities

As with Java, in Ruby...

  • memory is managed for you via a garbage collector.
  • there's public, private, and protected methods.
  • you've got embedded doc tools (Ruby's is called RDoc). The docs generated by rdoc look very similar to those generated by javadoc. RDoc can produce fairly good content even if the source contains no comments.


Differences

Unlike Java, in Ruby...

  • you don't need to compile your code. You just run it directly.
  • there's different GUI toolkits. Ruby users can try WxRuby, FXRuby, or the bundled-in Ruby Tk for example.
  • you use the end keyword after defining things like classes, instead of having to put braces around blocks of code.
  • you have require instead of import.
  • all member variables are private. From the outside, you access everything via methods.
  • parentheses in method calls are usually optional and often omitted.
  • everything is an object, including numbers like 2 and 3.14159. Classes are objects! For example, Array is a constant name that is bound to the Array class object. To create a new object, we call new on the class object as in  a = Array.new
  • there are no primitives or data types
  • variable names are just labels (not objects). They don't have a type associated with them.

  • there's no type declarations. You just assign to new variable names as-needed and they just "spring up" (i.e. a = [1,2,3] rather than int[] a = {1,2,3};).

  • it's foo = Foo.new("hi") instead of foo = new Foo( "hi" )

  • the constructing and initializing phases of an object are separate and both can be over-ridden. The initialization is done via the initialize instance method while the construction is done via the new class method.  initialize is not a constructor!

  • you have "mixin's" instead of interfaces. mixins are examples of implementation inheritance, they are not equivalent to Java interfaces
  • YAML tends to be favoured over XML.

  • it's nil instead of null. Also, nil is a normal object; you can never get a null pointer error!

  • there is no method overloading.

  • it's much more common to put many classes in the same file.

  • strings are mutable, unless you freeze them



Learning Ruby Navigation                                                                               <Ruby Tools  | TOC  |  JRuby Tutorial>