InterviewSolution
| 1. |
What type of programming language is Ruby and how is it different from compiled language(Java)? |
|
Answer» Ruby is an open source scripting language and Java is a compiled language. Ruby is mostly focused on simplicity and productivity. Ruby has a simple syntax that is natural to read and easy to write. Ruby is completely free, It is not only free of charge but free to use, copy, modify and distribute. Ruby code is executed only once that is at runtime. Java code is executed TWICE, compile time and runtime. Both Ruby and Java are Object-Oriented Languages. Ruby is DYNAMICALLY typed which means TYPE checking is done at runtime whereas Java is statically typed which means type checking is done to compile time. Ruby the code written will be validated during execution by the interpreter. In Ruby, everything is an Object. Ruby's pure Object-Oriented approach can be demonstrated with an example below 5.times { "Hello Ruby" } You can see how action being applied to a number. Ruby is seen as a FLEXIBLE language, as it allows the users to freely alter its code. Ruby blocks are also seen as a source of flexibility. A programmer can attach a closure to a method, altering how that method should act. the closure is called a block. Unlike other Object-Oriented Languages. Ruby features single inheritance only. Ruby features the concept of modules which adds great flexibility to add methods or variables to required CLASSES. |
|