like Java, C, C++, Python. But have you ever written a
code using Ruby, most probably No. but yet it’s one of
the most popular languages.
So i thought of writing about this language. Let’s see what Ruby is capable of.
What is Ruby?
Ruby is a beautiful, artful more like natural language created by Yukihiro “Matz” Matsumoto by blending parts of his favourite languages(Perl, Smalltalk, Eiffel, Ada and Lisp). He created this new language to balance Functional programming and Imperative programming.
Actually Ruby is a dynamic, open source language which is everything about objects.
When it comes to other object oriented languages like JAVA, they are not everything defining as objects. They leave Numbers and other primitive types out of it. But Ruby doesn’t do so. It gives methods and instance variables to all of it’s types. For an example,
5.times { print "We *love* Ruby -- it's outrageous!" }
As you can see in the example, Ruby allows to apply actions to numbers too.
So every rule for objects applies to everything in Ruby!!
This is the most wonderful thing you see in Ruby.
I think you got the idea of what it is like to be coding with ruby. But this is not all.
Some Features in Ruby
- Ruby is not hard on codes. That means ruby allows you to have your own methods redefined as you prefer. It is very close to our spoken language. For an example, In addition, instead of using ‘+’ operator, Ruby allows you to define a plus method in numerical class.
class Numeric
def plus(x)
self.+(x)
end
end
y = 5.plus 6
self.+(x)
end
end
y = 5.plus 6
Since Ruby is not restricting the coder, this may lead to many errors. But no worries, Ruby is more forgiving of errors. You’ll still be able to compile and run your program until you hit the problematic part.
- Ruby does not support multiple inheritance. Instead of that classes can import collection of methods as mixins. Mixin a module means receive all its methods for free which is much more clearer than multiple inheritance.
- Ruby wants to keep instance variables as private which can only be accessed using accessor methods(attr -writer, attr_reader). These accessor methods can be created with a single line of code, but also allow to declare ‘set’ and ‘get’ methods in traditional way.
- Ruby has exception handling features to make it easy to handle errors. An exception is raised with a ‘raise’ call. An Exception is handled by the ‘rescue’ clause.(‘catch’ clause in Java).
- A simple ‘Hello World’ in Ruby:
puts 'Hello World!'
- As you can see in this example code, it has used @ sign before the variable ‘name’. The specialty in Ruby is that it needs no variable declarations. Uses simple naming conventions.
- var could be a local variable.
- @var is an instance variable.
- $var is a global variable.
Even though Ruby is a natural language, it is not easy to maintain. Because in Ruby same thing can easily be defined as a different context. When the app grows larger and complex it will get hard to track down errors, and fix them. So this needs a good experience.
Also Ruby is kind a slow compared to Java language. Since this is a dynamically typed language, Ruby becomes slow because of its too much flexibility.
Yet Ruby community is the 8th largest Stack Overflow Community, 5th largest Meetup Community, 3rd most tagged language at GitHub and the 10th most popular language on the TIOBE index.
Ruby has started opening up lot of career opportunities around the global community.
For more information visit :
Start simple !!
Try Ruby here:
Great Maneesha... Keep it up
ReplyDeleteThanks aiyye
DeleteGood One (Y)
ReplyDeleteThanks webster
DeleteGreat stuff akki..!!!
ReplyDeletethank you malli
DeleteGood job manisha..!!
ReplyDeletethanks dr
DeleteTagged "iron clipper" - Tatiana - Titanium Hair Clipper - Titanium
ReplyDeletetatiana tatiana tatiana tatiana tatiana tatiana tatiana tatiana babyliss pro nano titanium curling iron tatiana guy tang titanium toner tatiana tatiana tatiana tatiana tatiana tatiana toaks titanium tatiana tatiana tatiana tatiana titanium bmx frame tatiana tatiana tatiana tatiana tatiana microtouch titanium trim reviews tatiana tatiana tatiana tatiana tatiana tatiana