Java Vs Ruby

Bhavika Bansal
2 min readJul 24, 2020

--

Here, you will find some of the interesting differences between Java and Ruby.

Interpreted or compiled

As you know, for interpreted languages there is no need to compile the code into machine-language instructions before executing most of its implementation. For compiled technologies, we need compilers to generate machine code from the source one. Everything is clear with Ruby — it’s an interpreted language. As for Java, you can find a lot of sources claiming that it’s strictly compiled. At the same time, along with JIT (just-in-time) compilation of the byte code from the Java compiler, some JVM implementations may interpret the byte code as well. It is not an interpreter that you can observe in other programming languages like Ruby, but it’s also possible to interpret the Java code directly. So, Java can be called both an interpreted and compiled technology.

Compiler Vs Interpreter

Figure below represents, how java works as both compiled and interpreted language.

Pure object-oriented or hybrid object-oriented

We know that Ruby defines everything as an object including all predefined and user-defined types. It is a pure object-oriented language. Java does not fall under this category because of the eight primitive types (byte, short, int, long, float, double, char, and boolean) that are not classified as objects. Hence, it is not a pure OOP technology and is usually referred to as a hybrid one.

Primitive int in java

Operator overloading

As for operator overloading, Ruby supports the feature that allows developers to define an operator (+ or *) for user-defined types, while Java does not.

Overloading “+” in ruby

--

--

Bhavika Bansal
Bhavika Bansal

No responses yet