I love ruby because -
Expressiveness
Yeah, remember those powerful one liners. Added with power of awesome iterators and blocks, a lot can be achieved in just one line here..
I remember a classic problem that they give to freshers to solve while recruiting - Interchange values of a
and b
, without using a third variable. People come up with various solution using + and -, in around 5 to 10 lines. But here, its just ;-)
a, b = b, a
Reflection -
All other languages, when running, becomes byte code or machine code, and forget about classes and objects. While ruby is a languages, which remembers classes and objects while running. This enables ruby to have metaprogramming.
Power of having classes and objects in memory while code executes has lot of benefits. Not just for inspection of classes, modules or there methods. But for -
- Creation of classes and modules at runtime.
- Adding methods to exiting classes or objects.
Ruby Syntex -
Ruby allow a lot of syntex sugar. Optional closing brackets for params to function calls everything is possible. Syntex makes things pretty simple as well, for e.g. hello word program in here is just puts "hello word"