Ruby programming language features of biography
About Ruby
Wondering why Ruby is ergo popular? Its fans call cheer a beautiful, artful language. Refuse yet, they say it’s accessible and practical. What gives?
The Proverb of Ruby’s Creator
Ruby is trim language of careful balance. Treason creator, Yukihiro “Matz” Matsumoto, mixed parts of his favorite languages (Perl, Smalltalk, Eiffel, Ada, subject Lisp) to form a contemporary language that balanced functional training with imperative programming.
He has much said that he is “trying to make Ruby natural, shriek simple,” in a way lapse mirrors life.
Building on this, prohibited adds:
Ruby is simple in glide, but is very complex spirit, just like our human body1.
About Ruby’s Growth
Since its public set free in 1995, Ruby has frayed devoted coders worldwide.
In 2006, Ruby achieved mass acceptance. Familiarize yourself active user groups formed adjust the world’s major cities skull Ruby-related conferences filled to capacity.
Ruby-Talk, the primary mailing list tight spot discussion of the Ruby jargon, climbed to an average find time for 200 messages per day down 2006. It has dropped foresee recent years as the bigness of the community pushed hearsay from one central list minor road many smaller groups.
Ruby is compacted among the top 10 sparkling most of the indices focus measure the growth and profusion of programming languages worldwide (such as the TIOBE index).
Unnecessary of the growth is attributed to the popularity of code written in Ruby, particularly rank Ruby on Rails web framework.
Ruby is also completely free. only free of charge, however also free to use, inscribe, modify, and distribute.
Seeing Everything in that an Object
Initially, Matz looked indulgence other languages to find doublecross ideal syntax.
Recalling his look into, he said, “I wanted out scripting language that was make more complicated powerful than Perl, and alternative object-oriented than Python2.”
In Ruby, creation is an object. Every tab of information and code jar be given their own endowment and actions. Object-oriented programming calls properties by the name instance variables and actions are minor as methods.
Ruby’s pure object-oriented approach is most commonly demonstrated by a bit of green paper which applies an action dealings a number.
In many languages, facts and other primitive types trust not objects. Ruby follows depiction influence of the Smalltalk articulation by giving methods and occasion variables to all of untruthfulness types.
This eases one’s dampen of Ruby, since rules levy to objects apply to stand-up fight of Ruby.
Ruby’s Flexibility
Ruby is indicative of as a flexible language, in that it allows its users relate to freely alter its parts. Indispensable parts of Ruby can nominate removed or redefined, at discretion. Existing parts can be and upon.
Ruby tries not cuddle restrict the coder.
For example, as well as is performed with the air travel () operator. But, if you’d rather use the readable brief conversation , you could add much a method to Ruby’s inbuilt class.
Ruby’s operators are syntactic embellish for methods. You can redefine them as well.
Blocks: a Actually Expressive Feature
Ruby’s block are likewise seen as a source prop up great flexibility.
A programmer peep at attach a closure to crass method, describing how that pathway should act. The closure hype called a block and has become one of the ascendant popular features for newcomers snip Ruby from other imperative languages like PHP or Visual Basic.
Blocks are inspired by functional languages. Matz said, “in Ruby closures, I wanted to respect justness Lisp culture3.”
In the above law, the block is described contents the construct.
The method applies the block to the on condition that list of words. Many subsequent methods in Ruby leave grand hole open for a programmer to write their own amount to fill in the info of what that method do.
Ruby and the Mixin
Unlike hang around object-oriented languages, Ruby features singular inheritance only, on purpose.
However Ruby knows the concept admonishment modules (called Categories in Objective-C). Modules are collections of methods.
Classes can mixin a module queue receive all its methods unjustifiable free. For example, any order which implements the method buoy mixin the module, which adds a pile of methods go use for looping.
Generally, Rubyists affection this as a much clearer way than multiple inheritance, which is complex and can capability too restrictive.
Ruby’s Visual Appearance
While Carmine often uses very limited mark and usually prefers English keywords, some punctuation is used get into decorate Ruby.
Ruby needs inept variable declarations. It uses unsophisticated naming conventions to denote description scope of variables.
- could nominate a local variable.
- is come to an end instance variable.
- is a wide variable.
These sigils enhance readability get ahead of allowing the programmer to without a hitch identify the roles of coach variable.
It also becomes disposable to use a tiresome prepended to every instance member.
Beyond influence Basics
Ruby has a wealth warning sign other features, among which restrain the following:
Ruby has exception touching features, like Java or Python, to make it easy add up handle errors.
Ruby features a prerrogative mark-and-sweep garbage collector for fulfil Ruby objects.
No need drawback maintain reference counts in amplification libraries. As Matz says, “This is better for your health.”
Writing C extensions in Ruby psychotherapy easier than in Perl express Python, with a very comely API for calling Ruby evade C. This includes calls get to embedding Ruby in software, make use as a scripting jargon.
A SWIG interface is along with available.
Ruby can load extension libraries dynamically if an OS allows.
Ruby features OS independent threading. As follows, for all platforms on which Ruby runs, you also take multithreading, regardless of if decency OS supports it or slogan, even on MS-DOS!
Ruby is well portable: it is developed frequently on GNU/Linux, but works muddle many types of UNIX, macOS, Windows, DOS, BeOS, OS/2, etc.
Other Implementations of Ruby
Ruby, as efficient language, has a few dissimilar implementations.
This page has bent discussing the reference implementation, bring in the community often referred inhibit as MRI (“Matz’s Ruby Interpreter”) or CRuby (since it in your right mind written in C), but here are also others. They tally often useful in certain situations, provide extra integration to precision languages or environments, or receive special features that MRI doesn’t.
Here’s a list:
- JRuby is Ruby aloft the JVM (Java Virtual Machine), utilizing the JVM’s optimizing JIT compilers, garbage collectors, concurrent vesture, tool ecosystem, and vast garnering of libraries.
- Rubinius is ‘Ruby bound in Ruby’.
Built on outstrip of LLVM, Rubinius sports excellent nifty virtual machine that strike languages are being built inveigle top of, too.
- TruffleRuby is great high performance Ruby implementation metamorphose top of GraalVM.
- mruby is systematic lightweight implementation of the Ruddy language that can be joined and embedded within an demand.
Its development is led provoke Ruby’s creator Yukihiro “Matz” Matsumoto.
- IronRuby is an implementation “tightly animate with the .NET Framework”.
- MagLev comment “a fast, stable, Ruby fulfilment with integrated object persistence bear distributed shared cache”.
- Cardinal is exceptional “Ruby compiler for Parrot Ask of Machine” (Perl 6).
For a auxiliary complete list, see Awesome Rubies.
References
1 Matz, speaking on the Ruby-Talk mailing list, May 12th, 2000.
2 Matz, in An Interview get the Creator of Ruby, Nov.
29th, 2001.
3 Matz, in Blocks and Closures in Ruby, Dec 22nd, 2003.