1. Technology
Send to a Friend via Email
You can opt-out at any time. Please refer to our privacy policy for contact information.

How Does Ruby Compare to the Java Programming Language?

Comparing Ruby to the Java Programming Language


Common Elements

Ruby and the Java programming language have a lot in common, beginning with the fact that they both follow some of the same object-oriented principles. Everything is an object in Ruby and--with a few small exceptions--that's true for Java as well. Both languages pass objects by reference and both languages are garbage collected (which, by the way, is not a sanitation issue, but a memory management system).

Comparing Code Execution

The real difference between the Ruby and Java programming languages lie in the method of executing code. Java code is first translated to a virtual machine language (that is, converted to a machine language for a simulated computer). Code executed on this virtual machine executes faster than Ruby's interpreted code. With the exception of JRuby--which is itself implemented in Java--Ruby's current implementations are interpreted without translating to a virtual machine language first.

Differences in Syntax

Java's syntax is vastly different than Ruby's, too. The Java programming language follows a strict c-like syntax whereas Ruby's loose syntax frequently allows for things to be omitted. A good way to look at this difference is to compare the grammatical rules you'd have to follow when writing a term paper versus the freedom of language that text messaging provides.

Java uses a hefty set of mandatory keywords. In Ruby? Well, unless something other than the default is needed, some things are better left unsaid.

  1. About.com
  2. Technology
  3. Ruby
  4. Beginning Ruby
  5. How Does Ruby Compare to the Java Programming Language?

©2014 About.com. All rights reserved.