AskBiography Logo   Latest News  Follow Us on Twitter  Follow Us on Google Buzz  Became Fan - Facebook  Subscribe to RSSRSS   Bookmark and Share

Ruby (programming language)

Ruby (programming language)
Programming language
Appeared in1995
Designed byYukihiro Matsumoto
Software developerYukihiro Matsumoto, et al.
Stable release1.9.2-p180 (February 18, 2011)
Typing disciplineduck, dynamic, strong
Major implementationsRuby MRI, YARV, JRuby, Rubinius, IronRuby, MacRuby, HotRuby
Influenced byAda, C++, CLU, Dylan, Eiffel, Lisp, Perl, Python, Smalltalk
InfluencedGroovy, Nu, Falcon, Ioke, Mirah
Operating systemCross-platform
LicenseRuby License or GNU General Public License v2
Usual file extensions.rb, .rbw

     Home | programming language | Ruby (programming language)

Ruby is a dynamic, reflective, general-purpose object-oriented programming language that combines syntax inspired by Perl with Smalltalk-like features. Ruby originated in Japan during the mid-1990s and was first developed and designed by Yukihiro "Matz" Matsumoto. It was influenced primarily by Perl, Smalltalk, Eiffel, and Lisp.

Ruby supports multiple programming paradigms, including functional, object oriented, imperative and reflective. It also has a dynamic type system and automatic memory management; it is therefore similar in varying respects to Python, Perl, Lisp, Dylan, Pike, and CLU.

The standard 1.8.7 implementation is written in C, as a single-pass interpreted language. There is currently no specification of the Ruby language, so the original implementation is considered to be the de facto reference. , there are a number of complete or upcoming alternative implementations of the Ruby language, including YARV, JRuby, Rubinius, IronRuby, MacRuby, and HotRuby. Each takes a different approach, with IronRuby, JRuby and MacRuby providing just-in-time compilation and MacRuby also providing ahead-of-time compilation. The official 1.9 branch uses YARV, as will 2.0 (development), and will eventually supersede the slower Ruby MRI.

Ruby (programming language) Video Learn to program Ruby with videos, a free eBook and the source code of all the example programs. This tutorial covers Chapter One of The Little Book Of Ruby which you can download from the SapphireSteel Software web site, the company behind the Ruby In Steel (Ruby 'Ruby On Rails') and Amethyst (Flex) IDEs for Visual Studio.
3.87 min. | 4.48 user rating Learn to program Ruby with videos, a free eBook and the source code of all the example programs. This tutorial introduces the fundamentals of object orientation including how to define classes with methods and instance variables; and how to construct new objects and initialize them with data. For more information, read Chapter Two of The Little Book Of Ruby which you can download from the SapphireSteel Software web site, the company behind the Ruby In Steel and Amethyst Flex IDEs for Visual Studio.
6.62 min. | 4.95 user rating
This tutorial is an extension to my last one about programming GUI interfaces in Ruby in Steel. This time, we are using a more platform independent toolkit to easily creating native widget applications that work very well. As you are probably well aware, Ruby does not have too many solid solutions to creating desktop applications, so I am showing you one of them. Follow me on Twitter for more programming updates Thanks for watching, and feel free to subscribe.
10.00 min. | 4.41 user rating Learn to program Ruby with videos, a free eBook and the source code of all the example programs. This tutorial discusses class hierarchies and object inheritance. For more information, read Chapter Three of The Little Book Of Ruby which you can download from the SapphireSteel Software web site, the company behind the Ruby In Steel (Ruby) and Amethyst (Flash Platform) IDEs for Visual Studio.
4.43 min. | 4.75 user rating
Google Tech Talk July 28, 2010 Presented by Charles Oliver Nutter and John Woodell. ABSTRACT Much has been made of having more expressive languages for the JVM. The recent explosion of interest in alternative JVM languages has shown there's a need for something better. But have Scala, Groovy, Fantom achieved this goal? We'll look at Mirah, which attempts to implement Ruby's apparent features directly atop JVM types and code. In each case there have been gains and losses. Ruby often provides beautiful abstractions, but sometimes requires odd things of the JVM that influence performance. The dynamic capabilities are incredibly expressive, but we often need more static structure to enforce typing guarantees or integrate with the platform. On top of all this, much of Ruby's dynamism makes it very difficult to optimize on the JVM. Can we get those features in another way? Mirah may be one answer. It takes as a starting point the "apparent features" of Ruby, and as an end point the basic structures of the JVM, and attempts to tie them directly together. With a fairly simple compiler, Mirah can almost mimic the most common Ruby abstractions, but with static typing guarantees and no runtime library requirements. It provides a Ruby-like way to write Java, the ultimate goal of so many JVM languages. Charles Oliver Nutter has been programming most of his life, as a Java developer for the past decade and as a JRuby developer for over four years. He co-leads the JRuby project, an <b>...</b>
27.05 min. | 4.83 user rating
This tutorial shows you how to use Ruby in Steel for Visual Studio to make nice graphical user interfaces, but still use your favorite language (Ruby) to code the functionality. To download Ruby in Steel, go here: For more tech updates, you can follow me on twitter:
8.52 min. | 4.2 user rating
Hi ! This is the beta video of my programming language. Please give me suggestions on how I can improve the syntax. Also rate & comment ;) Thnx
4.25 min. | 4.0 user rating
Buy the book here: Andrei Alexandrescu discusses key concepts form his book, The D Programming Language, which not only introduces the D language—it presents a compendium of good practices and idioms to help both your coding with D and your coding in general.
7.85 min. | 4.87 user rating
I recommend C Download links: Microsoft Visual Basic/C family: Delphi: Python: Ruby: Assembly: Top Ten: Java: Eclipse: Perl: Notepad++:
8.70 min. | 1.0 user rating
This is the first in a series of videos about the code entries submitted for our recent "One New Thing" Development Challenge. All of the contest entries are available on the Xchange Beta site. Have you ever wanted to quickly experiment with a programming language's options? Did you want to test and verify how an option worked, but had to perform a lot of setup and configuration for a simple test? This is common request of developers; and programming languages like Ruby provide simple command-line interfaces for this type of experimenting. Thanks to Homan Chou, Demandware developers now have this ability. Homan created "Interactive Console," a module (also called a "cartridge" in Demandware terminology) that creates a command-line interface for DemandwareScript, enabling developers to test and experiment language syntax without the need to set up and instantiate a pipeline. The "Interactive Console" cartridge is just another example of how Demandware's SaaS commerce platform provides a robust development environment that enables companies to customize and extend any aspect of their store, but without the burden of handling infrastructure. Find out more about this on Demandware's website. Stay tuned for additional recaps of the other code entries submitted for the "One New Thing" Development Challenge. Can't wait? You can check out all of the contest entries on the Xchange Beta site.
2.97 min. | 0 user rating

Latest News : Ruby (programming language) : Tweet this RSS

Want to Ruby (programming language) latest news on your twitter account???   sign in with twitter
Ruby (programming language)     sign in with twitter   ||  programming_language     sign in with twitter   ||  Other     sign in with twitter
Recalling 1909: Ruby Geneva - Mcalester News Capital Tweet this news
Mcalester News Capital--By Leo Kelley Staff Writer When -Ruby- Geneva looks back into the reflection of the rear-view window of her life, she has a lot of looking to do, ... - Date : Mon, 25 Oct 2010 15:31:15 GMT+00:00
Unique Take on the Speed Game Concept at Ruby Bingo. - Gaming Supermarket Tweet this news
Gaming Supermarket--These days, speed games are all the rage and, though -Ruby- Bingo are certainly not the only site on the web in the business of offering a fast alternative to ... - Date : Mon, 25 Oct 2010 19:18:58 GMT+00:00
Transient killed in collision identified - Whittier Daily News Tweet this news
Whittier Daily News--WHITTIER - Coroner's officials have identified the pedestrian struck and killed Aug. 17 as a 64-year-old homeless man. ... - Date : Tue, 26 Oct 2010 02:03:45 GMT+00:00

'hot'} # Deletes :fire=> 'hot'

Blocks and iterators

The two syntaxes for creating a code block: { puts "Hello, World!" } # Note the { braces } #or do puts "Hello, World!" end When a code block is created it is always attached to a method as an optional block argument. Parameter-passing a block to be a closure: # In an object instance variable (denoted with '@'), remember a block. def remember(&a_block) @block=a_block end # Invoke the above method, giving it a block which takes a name. remember>
Collections :

"Hello, Jon!" Creating an anonymous function: proc>
Blocks and iterators :

Blocks and iterators :

Blocks and iterators :

Blocks and iterators :

Blocks and iterators :

Blocks and iterators :

Blocks and iterators :

Blocks and iterators :

Blocks and iterators :

Blocks and iterators :

Blocks and iterators :

[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]


The following code defines a class named Person. In addition to 'initialize', the usual constructor to create new objects, it has two methods: one to override the <=> comparison operator (so Array#sort can sort by age) and the other to override the to_s method (so Kernel#puts can format its output). Here, "attr_reader" is an example of metaprogramming in Ruby: "attr_accessor" defines getter and setter methods of instance variables, "attr_reader" only getter methods. Also, the last evaluated statement in a method is its return value, allowing the omission of an explicit 'return'. class Person attr_reader :name, :age def initialize(name, age) @name, @age=name, age end def <=>(person) # Comparison operator for sorting @age <=> person.age end def to_s "#@name (#@age)" end end group=["Bob", 33),"Chris", 16),"Ash", 23) ] puts group.sort.reverse The above prints three names in reverse age order: Bob (33) Ash (23) Chris (16)

Open classes

In Ruby, classes are never closed: you can always add methods to an existing class. This applies to the classes you write as well as the standard, built-in classes. All you have to do is open up a class definition for an existing class, and the new contents you specify will be added to whatever's there. A simple example of adding a new method to the standard library's Time class: # re-open Ruby's Time class class Time def yesterday self - 86400 end end #=> Thu Aug 14 16:51:50 +1200 2008 yesterday=today.yesterday #=> Wed Aug 13 16:51:50 +1200 2008 Adding methods to previously defined classes is often called monkey-patching. This practice, however, can lead to possible collisions of behavior and subsequent unexpected results, and is a concern for code scalability if performed recklessly.


An exception is raised with a raise call: raise An optional message can be added to the exception: raise "This is a message" You can also specify which type of exception you want to raise: raise ArgumentError, "Illegal arguments!" Alternatively, you can pass an exception instance to the raise method: raise"Illegal arguments!") This last construct is useful when you need to raise a custom exception class featuring a constructor which takes more than one argument: class ParseError < Exception def initialize input, line, pos super "Could not parse '#{input}' at line #{line}, position #{pos}" end end raise"Foo", 3, 9) Exceptions are handled by the rescue clause. Such a clause can catch exceptions which inherit from StandardError. Also supported for use with exceptions are else and ensure begin # Do something rescue # Handle exception else # Do this if no exception was raised ensure # Do this whether or not an exception was raised end It is a common mistake to attempt to catch all exceptions with a simple rescue clause. To catch all exceptions one must write: begin # Do something rescue Exception # don't write just rescue -- that only catches StandardError, a subclass of Exception # Handle exception end Or catch particular exceptions: begin # ... rescue RuntimeError # handling end It is also possible to specify that the exception object be made available to the handler clause: begin # ... rescue RuntimeError=> e # handling, possibly involving e, such as "print e.to_s" end Alternatively, the most recent exception is stored in the magic global $!. You can also catch several exceptions: begin # ... rescue RuntimeError, Timeout::Error=> e # handling, possibly involving e end


Ruby code can programmatically modify, at runtime, aspects of its own structure that would be fixed in more rigid languages, such as class and method definitions. This sort of metaprogramming can be used to write more concise code and effectively extend the language. For example, the following Ruby code generates new methods for the built-in String class, based on a list of colors. The methods wrap the contents of the string with an HTML tag styled with the respective color. COLORS={ :black=> "000", :red=> "f00", :green=> "0f0", :yellow=> "ff0", :blue=> "00f", :magenta=> "f0f", :cyan=> "0ff", :white=> "fff" } class String COLORS.each do|color,code| define_method "in_#{color}" do "#{self}" end end end The generated methods could then be used like so: "Hello, World!".in_blue => "Hello, World!" To implement the equivalent in many other languages, the programmer would have to write each method (in_black, in_red, in_green, etc.) by hand. Some other possible uses for Ruby metaprogramming include: * intercepting and modifying method calls * implementing new inheritance models * dynamically generating classes from parameters * automatic object serialization * interactive help and debugging

More examples

More sample Ruby code is available as algorithms in the following articles: * Exponentiating by squaring * Trabb Pardo-Knuth algorithm


  The newest version of Ruby, the recently released version 1.9, has a single working implementation written in C that utilizes a Ruby-specific virtual machine. Ruby version 1.8 has three main implementations: The official Ruby interpreter often referred to as the Matz's Ruby Interpreter or MRI, which is the most widely used, and JRuby, a Java-based implementation that runs on the Java Virtual Machine, and Rubinius, a reimplementation of Ruby focusing on writing as much of the core in Ruby as possible. There are other less-known or upcoming implementations such as Cardinal (an implementation for the Parrot virtual machine), IronRuby (alpha version available since July 24, 2008), MacRuby, MagLev, Ruby.NET, XRuby and HotRuby (runs Ruby source code on a web browser and Flash). The maturity of Ruby implementations tends to be measured by their ability to run the Ruby on Rails (Rails) framework, because it is a complex framework to implement, and it uses many Ruby-specific features. The point when a particular implementation achieves this goal is called The Rails singularity. The reference implementation (MRI), JRuby, and Rubinius are all able to run Rails unmodified in a production environment. IronRuby is starting to be able to run Rails test cases, but is still far from being production-ready. Ruby is available on many operating systems such as Linux, Mac OS X, Microsoft Windows, Windows Phone 7, Windows CE and most flavors of Unix. Ruby 1.9 has recently been ported onto Symbian OS 9.x.

Repositories and libraries

The Ruby Application Archive (RAA), as well as RubyForge, serve as repositories for a wide range of Ruby applications and libraries, containing more than seven thousand items. Although the number of applications available does not match the volume of material available in the Perl or Python community, there are a wide range of tools and utilities which serve to foster further development in the language. RubyGems has become the standard package manager for Ruby libraries. It is very similar in purpose to Perl's CPAN, although its usage is more like apt-get. Recently, many new and existing libraries have found a home on GitHub, which is focused on Git and used to have native support for RubyGems packaging.


Blocks and iterators :

IDENetBeans * RubyForge * RadRails * RubyMine * ActiveState_Komodo
ImplementationsRuby MRI * YARV * JRuby * IronRuby * Rubinius * XRuby * MacRuby * RubyJS * HotRuby
ApplicationsRubyGems * Rake * Interactive Ruby Shell * Capistrano
Libraries / FrameworksAdhearsion * Camping * eRuby (RHTML) * Hobo * Merb * Nitro * RubyCocoa * Ruby on Rails * Ramaze * Sinatra * Padrino * QtRuby
Server SoftwareMongrel * Phusion Passenger (mod_rails/mod_rack) * WEBrick * mod_ruby
OtherApplication Archives * Document format * Book Guides * Ruby Central * Hackety Hack

Privacy | Sitemap | Micra Hosting