What are the main differences and similarities in java and ruby?

I am a professional java, now I like to go on ruby. Are there any similarities in both languages? and what are the main differences? Because both objects are object oriented.

+5
source share
4 answers

How about these:

Similarities

As in Java, in Ruby, ...

  • The memory is managed for you through the garbage collector.
  • Objects are strongly typed.
  • Public, private, and secure methods exist.
  • There are built-in doc tools (Rubys is called RDoc). The documents created by rdoc are very similar to the documents created by javadoc.

Differences

Unlike Java, in Ruby, ...

  • You do not need to compile your code. You just run it directly.
  • - . .
  • , , 2 3.14159.
  • .
  • - . , .
  • . , "spring " (.. a = [1,2,3], int [] a = {1,2,3};).
  • Theres no casting. .
  • "initialize" .
  • "mixins" .
  • == equals() - Ruby. ==, Ruby (equals() - Java). equal? ​​(), , (== Java).

: Ruby From Java

+15

-, . Java - , ruby ​​- . . Java c- , ruby ​​ .

Java , Ruby .

, , .

+6

. , , , ; ?

, , . , .

, , . , .

, , , . () , , , , , . . , .

Java Ruby. , , , .

, . , , " Ruby" Java. , . , , . , , , . , , . ( , "", , , "" .)

Ruby. . , .

+4
  • - Ruby Java. Ruby , ( Java), integer.
  • Ruby . , , Ruby:

    animal = Animal.new

  • Ruby - , . - , Ruby .

  • Ruby - mixin ( ), Java .
  • Ruby , Java. IMHO Ruby .

Therefore, I can say that in Java and Ruby there is not too much in common. Until today, I cannot find any similarities between them, since Ruby has gone its own way, unlike many other languages ​​that come from C.

+1
source

All Articles