Tuesday, May 27, 2014

Ruby: Why a blood-red colored gemstone can be so attractive?


What kind of language Ruby is and what kind of problems is suitable for?


What initially attracted me to Ruby was that it's creator has a focus on helping developers to be productive and happy.
It was a refreshing attitude. As I started using the language I've found that Ruby allows me to write very clean and readable code with minimal levels of syntactic and semantic noise.
It also comes with a huge amount of useful functionality built into it's standard library.
Ruby was first released in 1995 and over the years a large ecosystem of third-party libraries and frameworks grew around it. Particularly in the web development arena.




How does ruby compare to other languages?


Ruby started to be object-oriented has it was inspired by smalltalk. There are few primitives and many things in Ruby are expressed in terms of objects and methods. Is it based on dynamic typing and duck typing.

Dynamic Typing means that a variable can refer to objects of different types during the course of program execution.
Duck Typing means that valid semantics aren't determined by the object type. Instead it's enough for the object to have the methods which the operation uses. This allows you to have polymorphism without inheritance so class hierarchy can be a lot simpler. It also give you the opportunity to write more generic code.

The flip side is that it may require more discipline from the programmers working on the code base.

In addition to object-oriented style of programming, Ruby is flexible enough to allow functional and procedural styles of programming.

Ruby has a lot of facilities for reflection. It can get a lot of information at run-time such as class methods, in-heritage hierarchies and so on...

Another aspect of Ruby is that it provides rich opportunities for meta-programming by a vary of hook methods as well as the ability to create classes and methods dynamically.

The widely used implementations of Ruby are bytecode interpreted. This can put some limitations on performance.
The official implementation is called MRI which stands for Matz's Ruby Interpreter.
Another popular implementation is JRuby which is build on top of JVM (Java Virtual Machine).
On the Mac there's another Ruby implementation called MacRuby that can perform both just in time and ahead of time compilation of Ruby code.

No comments:

Post a Comment