LinuxDevCenter.com -- An Introduction to Ruby
var _hbEC=0,_hbE=new Array;function _hbEvent(a,b){b=_hbE[_hbEC++]=new Object();b._N=a;b._C=0;return b;} var hbx=_hbEvent("pv");hbx.vpc="HBX0100u";hbx.gn="ehg-oreilly.hitbox.com"; //"BCB: linuxdevcenter.com,/a/linux/2001/10/25/ruby.html, DM5503080AFA"; hbx.acct="DM5503080AFA;DM520404M4ZR"; //ACCOUNT NUMBER(S) hbx.pn="An+Introduction+to+Ruby"; //PAGE NAME(S) hbx.mlc="/a/linux/2001/10/25/;/linuxdevcenter.com/a/linux/2001/10/25/"; //MULTI-LEVEL CONTENT CATEGORY hbx.pndef="title"; //DEFAULT PAGE NAME hbx.ctdef="full"; //DEFAULT CONTENT CATEGORY hbx.lt="auto"; //LINK TRACKING hbx.dlf="n"; //DOWNLOAD FILTER hbx.dft="n"; //DOWNLOAD FILE NAMING hbx.elf="n"; //EXIT LINK FILTER //SEGMENTS AND FUNNELS hbx.seg=""; //VISITOR SEGMENTATION hbx.fnl=""; //FUNNELS //CAMPAIGNS hbx.cmp=""; //CAMPAIGN ID hbx.cmpn="CMP"; //CAMPAIGN ID IN QUERY hbx.hra=""; //RESPONSE ATTRIBUTE hbx.hqsr=""; //RESPONSE ATTRIBUTE IN REFERRAL QUERY hbx.hqsp="ATT"; //RESPONSE ATTRIBUTE IN QUERY hbx.hlt=""; //LEAD TRACKING hbx.hla=""; //LEAD ATTRIBUTE hbx.gp=""; //CAMPAIGN GOAL hbx.gpn=""; //CAMPAIGN GOAL IN QUERY hbx.hcn=""; //CONVERSION ATTRIBUTE hbx.hcv=""; //CONVERSION VALUE hbx.cp="null"; //LEGACY CAMPAIGN hbx.cpd=""; //CAMPAIGN DOMAIN //CUSTOM VARIABLES hbx.ci="";//CUSTOMER ID hbx.hc1="";//CUSTOM 1 hbx.hc2="";//CUSTOM 2 hbx.hc3="";//CUSTOM 3 hbx.hc4="";//CUSTOM 4 hbx.pec="";//ERROR CODES

 
Sign In/My Account | View Cart
#search-box {
background-color:#F6F6F6;
border-bottom:1px solid #CCCCCC;
padding-top:11px;
text-align:center;
}
#search-form {
margin:0pt auto;
text-align:left;
width:400px;
}
#search-title {
color:#888888;
display:block;
float:left;
font-size:17px;
padding:5px 5px 4px 0pt;
}
#search-input {
background:transparent url(http://www.oreilly.com/images/oreilly/search_bar_mid.gif) repeat-y scroll left top;
display:block;
float:left;
padding:0pt 5px 0pt 0pt;
width:260px;
}
#search-input-top {
background:transparent url(http://www.oreilly.com/images/oreilly/search_bar_top.gif) no-repeat scroll left top;
display:block;
width:260px;
}
#search-input-bot {
background:transparent url(http://www.oreilly.com/images/oreilly/search_bar_bot.gif) no-repeat scroll left bottom;
display:block;
width:260px;
}
#search-field {
float:left;
}
#search-field input {
background:transparent none repeat scroll 0%;
border:0pt none;
color:#990000;
font-family:Verdana,Arial,Helvetica,sans-serif;
font-size:16px;
margin:0pt;
padding:3px 0pt 4px 10px;
width:215px;
}
#search-field input:focus {
outline-color:invert;
outline-style:none;
outline-width:0pt;
}
#search-button {
float:right;
}
#search-button input {
font-size:0pt;
height:18px;
line-height:0pt;
margin:4px 4px 2px 0pt;
padding:0pt;
width:28px;
}
#search-tips {
display:block;
float:left;
font-size:10px;
padding:6px 0pt 0pt;
}
#search label {
text-transform:uppercase;
}
#search legend {
display:none;
}
#search label {
left:-9999px;
position:absolute;
}
fieldset {
border:0pt none;
margin:0pt;
padding:0pt;
}
.clear {
display:block;
line-height:0pt;
}
#wrapper {
margin:1em 0pt 2em 19em;
overflow:hidden;
}
#features {
float:left;
margin:0pt;
padding:0pt 2em 0pt 0pt;
width:41em;
a{text-decoration:none;}
#search-box{
padding-top: 11px;
padding-bottom: 0pt;
background-color: #f6f6f6;
border-bottom-width: 1px;
border-top-style: solid;
border-top-width: 1px;
border-top-color: #cccccc;
border-bottom-style: solid;
border-bottom-color: #cccccc;
text-align: center;
}
We've expanded our Linux news coverage and improved our search! Search for all things Linux across O'Reilly!
Search
Search Tips
Listen PrintSubscribe to LinuxSubscribe to Newsletters
An Introduction to Ruby
by Colin Steele
10/25/2001
Ruby is an object-oriented scripting language that combines
the object-oriented programming (OOP) power of Smalltalk with the utility of Perl and the power of Python.
I can already hear you grumbling, "Oh, great, another language." Why
should you care? You're already up to your elbows in technologies to
learn, right? Well, call your significant other and tell him or her
you're going to be late tonight. And go get another Jolt. You're going to be hooked on Ruby for the simple reason that Ruby makes programming fun again (and that's what really counts).
This article introduces Ruby by examining the high-level properties
of the language as well as some important features that distinguish
it from other languages. We'll compare Ruby with Perl and Python. Along the way, I'll provide my personal take on Ruby, and why I think you'll love it as much as I do.
Traits That Recommend Ruby
Looking down on Ruby from 50,000 feet, we see it has several qualities
that recommend it as the next language you should learn, including its
consistency and elegance, OOP features, ease of use, extensibility,
and its applicability to rapid development.
But what exactly is Ruby? It's a weakly typed, interpreted,
cross-platform language implemented in C, written from the ground up
to be object-oriented. Ruby's been around since 1995, and has its
largest following in Japan, the home of Ruby's author, Yukihiro
Matsumoto, a.k.a. "Matz." Although Ruby is more popular in Japan than
Python, you may not have heard much about it, yet. Or, if you have, you may have heard that it's a "better Perl than Perl."
O'Reilly & Associates will release Ruby in a Nutshell in November 2001. Beta Sample Chapter 4, Standard Library Reference, is free online.
I think there's a large measure of truth in that statement. Ruby somehow manages to combine some of the best features of Smalltalk, C, Perl, and Python in a package so elegant and natural that I found myself hooked after just one day.
Some of Ruby's strongest traits are:
Consistency. This is perhaps the single most important trait
of Ruby. Like C, Ruby is a small language. It's a simple language,
and Matz has made sure that a small set of rules govern its design. The result is Ruby stays out of your way; you don't have to build scaffolding to get it to actually work on the problem at hand.
Elegantly object oriented. Ruby fully supports object-oriented programming, with a from-the-ground-up, internally consistent and straightforward object model. Ruby has all the
features you'd expect from an OOPL, including classes, methods, (single) inheritance, polymorphism, class methods, exceptions, and more. These features are designed from the beginning, not glued-on, which means Ruby doesn't have the little inconsistencies and gotchas you'll find elsewhere.
For example, remember when you were learning C++ and the difference
between pointer-to-function and pointer-to-member-function bit you on
the butt? Or in Perl and Python, where the object (or reference, or
string) is passed to your method as the first argument? Or the lack
of access controls in Perl. Or.... Well, you get the idea.
Easy to use. Ruby's consistency and its object model make it easy to use. The syntax is simple, clean, and readable, with an
expressiveness that gives your code a natural flow. Specific features of the language, such as the ability to pass code blocks on method invocations, make Ruby source wonderfully transparent. There's little of the "line noise" you find in other languages, and although there's also none of the
bondage-and-discipline nature you'll find in other languages, Ruby seems
to promote a sparse, readable, succinct coding style.
Easy to extend. Using its C-interface extension API, you can
create interfaces from Ruby code to existing third-party commercial or
noncommercial libraries, or selectively implement methods or classes in a lower-level programming language to improve performance.
Perfect for rapid development. Finally, because Ruby is an
interpreted language, it is ideally suited to rapid application
development. Write your code, run it, debug it, and run the modified code again--fast, simple, and fun. This low-torque, high-revolution
implementation style lets you flow more easily from conception to
incarnation as you code. The result can be a surprising increase in your productivity. Although Ruby can be used for large-scale, long-term projects, I now count it as my favorite language for prototyping and spike-solution development.
These aspects of Ruby arise from the design of the language, its purpose, and its heritage. But aside from these more abstract
positive qualities, there are several specific language features that you'll want to explore in Ruby. These include code blocks/closures, iterators, variable scoping by name, and its uniform object treatment.
Pages: 1, 2
Next Page
Tagged ArticlesPost to del.icio.usThis article has been tagged:ruby Articles that share the tag ruby:Rolling with Ruby on Rails (2837 tags)Ajax on Rails (525 tags)Rolling with Ruby on Rails, Part 2 (241 tags)The Builders of Basecamp (54 tags)Technologies to Watch: A Look at Four That May Challenge Javas Development Dominance (47 tags)View Allprogramming Articles that share the tag programming:Rolling with Ruby on Rails (1374 tags)Very Dynamic Web Interfaces (279 tags)Ajax on Rails (231 tags)Understanding MVC in PHP (202 tags)A Simpler Ajax Path (186 tags)View Allintroduction Articles that share the tag introduction:Demystifying LDAP (11 tags)A Beginner's Introduction to Perl 5.10 (7 tags)An Introduction to Ruby (6 tags)What Is the X Window System (5 tags)An Introduction to FOAF (2 tags)View Alloreilly Articles that share the tag oreilly:What Is Web 2.0 (2327 tags)A Simpler Ajax Path (19 tags)Ajax on Rails (17 tags)Wireless Mesh Networking (15 tags)Understanding MVC in PHP (12 tags)View All
// var akMode = 'SILENT';
var akApiKey = 'RecEngine-49CCF850-02C7-B730-5489-DB7D929405CD';
var akTarget = 'http://www.linuxdevcenter.com/pub/a/linux/2001/10/25/ruby.html';
var akItemTitle = 'An Introduction to Ruby';
// var akDescription = 'linuxdevcenter description';
var akThumbnailUrl = 'http://oreillynet.com/standard-tiles/linux/111-horse.jpg';
var akTargetType = 'article';
var akRegion = 'linuxdevcenter';
var akIntent = 'VIEW';
var akScript = document.createElement('script');
akScript.setAttribute('src','http://api.aggregateknowledge.com/2007/01/15/js/' + (new Date()).valueOf() % 3600000 + '.js');
document.getElementsByTagName('head')[0].appendChild(akScript);
Sponsored Resources
Inside Lightroom
_qacct="p-20l78bOOCbhcg";quantserve();
© 2008, O'Reilly Media, Inc.(707) 827-7000 / (800) 998-9938
All trademarks and registered trademarks appearing on oreilly.com are the property of their respective owners.
About O'Reilly
Privacy Policy
Contacts
Authors
Press Room
Jobs
User Groups
Academic Solutions
Newsletters
Writing for O'Reilly
RSS Feeds
Other O'Reilly Sites
O'Reilly Radar
Ignite
Tools of Change for Publishing
Digital Media
makezine.com
craftzine.com
hackzine.com
perl.com
xml.com
Sponsored Sites
Inside Aperture
Inside iPhone
Inside Lightroom
Inside Port 25
InsideRIA
_qacct="p-20l78bOOCbhcg";quantserve();
-->
.iTt{
FONT-FAMILY: Verdana, Arial, Helvetica;
FONT-SIZE: 11px;
FONT-STYLE: normal;
FONT-WEIGHT: normal;
COLOR: black;
BACKGROUND-COLOR: lightyellow;
BORDER: black 1px solid;
PADDING: 2px;
}
_uacct = "UA-31074-5";
urchinTracker();
|
|