[#4567] Re: What's the biggest Ruby development? — Aleksi Niemel<aleksi.niemela@...>

Dave said:

18 messages 2000/08/23
[#4568] Q's on Marshal — Robert Feldt <feldt@...> 2000/08/23

[#4580] RubyUnit testcase run for different init params? — Robert Feldt <feldt@...> 2000/08/25

[#4584] Re: RubyUnit testcase run for different init params? — Dave Thomas <Dave@...> 2000/08/25

Robert Feldt <feldt@ce.chalmers.se> writes:

[#4623] Re: RubyUnit testcase run for different init params? — Robert Feldt <feldt@...> 2000/08/28

On Sat, 26 Aug 2000, Dave Thomas wrote:

[#4652] Andy and Dave's European Tour 2000 — Dave Thomas <Dave@...>

24 messages 2000/08/30
[#4653] Re: Andy and Dave's European Tour 2000 — matz@... (Yukihiro Matsumoto) 2000/08/30

Hi,

[#4657] Ruby tutorials for newbie — Kevin Liang <kevin@...> 2000/08/30

Hi,

[ruby-talk:04322] Thirty-seven Reasons [Hal Fulton] Love[s] Ruby (long)

From: Conrad Schneiker <schneik@...>
Date: 2000-08-06 02:14:40 UTC
List: ruby-talk #4322
Hi,

The item that follows below is on
(http://www.hypermetrics.com/ruby37.html). I thought it would be
interesting for those who are looking into Ruby, or for those who are
new to Ruby and get asked why people think it is worth learning.

P.S.: For those of you who don't regularly visit the Ruby home page
(http://www.ruby-lang.org/en/), there is this interesting bit of news:
"Perl/Ruby Conference in Japan will be held from Nov. 29 to Dev. 1 at
Kyoto International Conference Hall. This conference is sponsored by
O'Reilly Japan and Japan Linux Association."

-- 
Conrad Schneiker
(This note is unofficial and subject to improvement without notice.)

=====================================================

Thirty-seven Reasons I Love Ruby

1.  It痴 object-oriented. What does that mean? Well, for every ten
programmers, there are twelve opinions as to what OOP is. I will leave
it your judgment. But for the record, Ruby does offer encapsulation of
data and methods within objects and allows inheritance from one class
to another; and it allows polymorphism of objects. Unlike some
languages (C++, Perl 5, etc.) Ruby was designed from the beginning to
be object-oriented.

2.  It痴 a pure OOP language. Am I being redundant? I don't think so.
By this we mean that everything, including primitive data types such
as strings and integers, is represented as an object. There is no need
for wrapper classes such as Java has. And in addition, even constants
are treated as objects, so that a method may be invoked with, for
example, a numeric constant as a receiver.

3.  It痴 a dynamic language. For people only familiar with more static
languages such as C++ and Java, this is a significant conceptual leap.
It means that methods and variables may be added and redefined at
runtime. It obviates the need for such features as C痴 conditional
compilation (#ifdef), and makes possible a sophisticated reflection
API. This in turn allows programs to become more 都elf-aware
enabling runtime type information, detection of missing methods, hooks
for detecting added methods, and so on. Ruby is related to Lisp and
Smalltalk in this respect.

4.  It痴 an interpreted language. This is a complex issue, and
deserves several comments. It can be argued that performance issues
make this a negative rather than a positive. To this concern, I reply
with these observations: 1. First and foremost: A rapid development
cycle is a great benefit, and it is encouraged by the interpreted
nature of Ruby. 2. How slow is too slow, anyway? Do some benchmarks
before you call it slow. 3. Though some will criticize me, I will say
this anyway: Processors are getting faster every year. 4. If you
absolutely need the speed, you can write part of your code in C. 5.
Finally, in a sense, it is all a moot point, since no language is
inherently interpreted. There is no law of the universe that says a
Ruby compiler cannot be written. 

5.  It understands regular expressions. For years, this was considered
the domain of UNIX weenies wielding clumsy tools such as grep and sed,
or doing fancy search-and-replace operations in vi. Perl helped change
that, and now Ruby is helping, too. More people than ever recognize
the incredible power in the super-advanced string and text
manipulation techniques. Doubters should go and read Jeffrey Friedl痴
book Mastering Regular Expressions. So should non-doubters.

6.  It痴 multi-platform. It runs on Linux and other UNIX variants, the
various Windows platforms, BeOS, and even MS-DOS. If my memory serves
me, there痴 an Amiga version.

7.  It痴 derivative. This is a good thing? Outside of the literary
world, yes, it is. Isaac Newton said, 的f I have seen farther than
others, it is because I stood on the shoulders of giants.Ruby
certainly has stood on the shoulders of giants. It borrows features
from Smalltalk, CLU, Lisp, C, C++, Perl, Kornshell, and others. The
principles I see at work are: 1. Don稚 reinvent the wheel. 2. Don稚
fix what isn稚 broken. 3. Finally, and especially: Leverage people痴
existing knowledge. You understand files and pipes in UNIX? Fine, you
can use that knowledge. You spent two years learning all the printf
specifiers?  Don稚 worry, you can still use printf. You know Perl痴
regex handling? Good, then you致e almost learned Ruby痴.

8.  It痴 innovative. Is this in contradiction to #7 above? Well,
partly; every coin has two sides. Some of Ruby痴 features are truly
innovative, like the very useful concept of the mix-in. Maybe some of
these features will be borrowed in turn by future languages.

9.  It痴 a Very High-Level Language (VHLL). This is subject to debate,
because this term is not in widespread use, and its meaning is even
more disputable than that of OOP. When I say this, I mean that Ruby
can handle complex data structures and complex operations on them with
relatively few instructions, in accordance with what some call the
Principle of Least Effort.

10.  It has a smart garbage collector. Routines like malloc and free
are only last night痴 bad dream. You don稚 even have to call
destructors. Enough said. 

11.  It痴 a scripting language. Don稚 make the mistake of thinking it
isn稚 powerful because of this. It痴 not a toy. It痴 a full-fledged
language that happens to make it easy to do traditional scripting
operations like running external programs, examining system resources,
using pipes, capturing output, and so on.

12.  It痴 versatile. It can do the things that Kornshell does well and
the things that C does well. You want to write a quick ten-line hack
to do a one-time task, or a wrapper for some legacy programs? Fine.
You want to write a web server, a CGI, or a chess program? Again,
fine.

13.  It痴 thread-capable. You can write multi-threaded applications
with a simple API. Yes, even on MS-DOS.

14.  It痴 open-source. You want to look at the source code? Go ahead.
Want to suggest a patch? Go ahead. You want to connect with a
knowledgeable and helpful user community, including the language
creator himself? You can.

15.  It痴 intuitive. The learning curve is low, and once you get over
the first hump, you start to 堵uesshow things workand your guesses
are often correct. Ruby endeavors to follow the Principle of Least
Astonishment (or Surprise).

16.  It has an exception mechanism. Like Java and C++, Ruby
understands exceptions. This means less messing with return codes,
fewer nested if statements, less spaghetti logic, and better error
handling.

17.  It has an advanced Array class. Arrays are dynamic; you don稚
have to declare their size at compile-time as in, say, Pascal. You
don稚 have to allocate memory for them as in C, C++, or Java. They池e
objects, so you don稚 have to keep up with their length; it痴
virtually impossible to 努alk off the endof an array as you might in
C. Want to process them by index? By element? Process them backwards?
Print them? There are methods for all these.  Want to use an array as
a set, a stack, or a queue? There are methods for these operations,
too. Want to use an array as a lookup table? That痴 a trick question;
you don稚 have to, since we have hashes for that.

18.  It痴 extensible. You can write external libraries in Ruby or in
C. In addition, you can modify the existing classes and objects at
will, on the fly.

19.  It encourages literate programming. You can embed comments in
your code which the Ruby documentation tool can extract and
manipulate. (Real fans of literate programming may think this is
pretty rudimentary.)

20.  It uses punctuation and capitalization creatively. A method
returning a Boolean result (though Ruby doesn稚 call it that) is
typically ended with a question mark, and the more destructive,
data-modifying methods are named with an exclamation point. Simple,
informative, and intuitive. All constants, including class names,
start with capital letters. All object attributes start with an @
sign. This has the pragmatism of the old 滴ungarian notationwithout
the eye-jarring ugliness.

21.  Reserved words aren稚. It痴 perfectly allowable to use an
identifier that is a so-called 途eserved wordas long as the parser
doesn稚 perceive an amibiguity. This is a breath of fresh air.

22.  It allows iterators. Among other things, this makes it possible
to pass blocks of code to your objects in such a way that the block is
called for each item in the array, list, tree, or whatever. This is a
powerful technique that is worth exploring at great length.

23.  It has safety and security features. Ruby borrows Perl痴 concept
of tainting and allows different levels of control (levels of
paranoia?) by means of the $SAFE variable. This is especially good for
CGI programs that people will try to subvert in order to crack the web
server.

24.  It has no pointers. Like Java, and with a grudging nod to C++,
Ruby does not have the concept of a pointer; there is no indirection,
no pointer arithmetic, and none of the headaches that go with the
syntax and the debugging of pointers. Of course, this means that real
nuts-and-bolts system programming is more difficult, such as accessing
a control-status register for a device; but that can always be done in
a C library. (Just as C programmers drop into assembly when necessary,
Ruby programmers drop into C when they have to!)

25.  It pays attention to detail. Synonyms and aliases abound. You
can稚 remember whether to say size or length for a string or an array?
Either one works. For ranges, is it begin and end, or first and last?
Take your pick. You spell it indices, and your evil twin spells it
indexes? They both work.

26.  It has a flexible syntax. Parentheses in method calls can usually
be omitted, as can commas between parameters. Perl-style quotes allow
arrays of strings without all the quotation marks and commas. The
return keyword can be omitted.

27.  It has a rich set of libraries. There is support for threads,
sockets, limited object persistence, CGI programs, server-side
executables, DB files, and more. There is some support for Tk, with
more on the way.

28.  It has a debugger. In a perfect world, we wouldn稚 need
debuggers. This is not a perfect world.

29.  It can be used interactively. Conceivably it could be used as a
sort of 適ornshell squared.

30.  It is concise. There are no superfluous keywords such as Pascal痴
begin, then after if, do after while. Variables need not be declared,
as they do not have types. Return types need not be specified for
methods. The return keyword is not needed; a method will return the
last evaluated expression. On the other hand... it is not so cryptic
as C or Perl. 

31.  It is expression-oriented. You can easily say things like x = if
a<0 then b else c.

32.  It is laced with syntax sugar. (To paraphrase Mary Poppins: A
spoonful of syntax sugar helps the semantic medicine go down.) If you
want to iterate over an array x by saying for a in x, you can. If you
want to say a += b instead of a = a + b, you can. Most operators are
really just methods with short, intuitive names and a more convenient
syntax.

33.  It has operator overloading. If I am not mistaken, this
originated long ago in SNOBOL, but was popularized more recently by
C++. It can be overdone or misused, but it can be nice to have.
Additionally, Ruby defines the assignment version of an operator
automagically; if you define +, you get += as a bonus.

34.  It has infinite-precision integer arithmetic. Who cares about
short, int, long? Just use a Bignum. Admit it, you always wanted to
find the factorial of 365. Now you can.

35.  It has an exponentiation operator. In the old days, we used this
in BASIC and FORTRAN. But then we learned Pascal and C, and learned
how evil this operator was. (We were told we didn稚 even know how the
evaluation was done did it use logarithms? Iteration? How efficient
was it?) But then, do we really care? If so, we can rewrite it
ourselves. If not, Ruby has the good old ** operator you loved as a
child. Enjoy it.

36.  It has powerful string handling. If you want to search,
substitute, justify, format, trim, delimit, interpose, or tokenize,
you can probably use one of the built-in methods. If not, you can
build on them to produce what you need. 

37.  It has few exceptions to its rules. The syntax and semantics of
Ruby are more self-consistent than most languages. Every language has
oddities, and every rule has exceptions; but Ruby has fewer than you
might expect.

In This Thread

Prev Next