Comp.lang.ruby FAQ

(HAL 9000) #1

RUBY NEWSGROUP FAQ -- Welcome to comp.lang.ruby! (Revised 2005-4-14)

This FAQ contains information for those who want to:

  1) learn more about Ruby, and want to
  2) post to comp.lang.ruby or to the ruby-lang mail list, or want to
  3) provide anonymous feedback to help us improve Ruby.

This FAQ will be posted monthly. If you are reading this material
via the mailing list or the newsgroup, note that you can find it on
the web at: http://rubyhacker.com/clrFAQ.html

A German version of this FAQ is maintained by Josef "Jupp" Schugt. It can be
found at: http://oss.erdfunkstelle.de/ruby/

Note that this is *not* the Ruby language FAQ! This can be found at:
http://www.rubygarden.org/iowa/faqtotum/

TABLE OF CONTENTS

    1 About Ruby
    1.1 What is Ruby?
    1.2 Where can I find out more about Ruby?
    2 About comp.lang.ruby.
    2.1 Tell me about comp.lang.ruby.
    2.2 Tell me the posting guidelines for comp.lang.ruby.
    2.3 Tell me about the prolific Matz poster.
    2.4 How do the mailing list and newsgroup interrelate?
    2.5 What are these 6-digit message numbers?
    2.6 What is "POLS"?
    3 Anything else?

1 About Ruby

1.1 What is Ruby?

    Ruby is a very high level, fully OO programming language. Indeed,
    Ruby is one of the relatively few pure OO languages. Yet despite
    its conceptual simplicity, Ruby is still a powerful and practical
    "industrial strength" development language.

    Ruby selectively integrates many good ideas taken from Perl,
    Python, Smalltalk, Eiffel, ADA, CLU, and LISP. Ruby combines
    these ideas in a natural, well-coordinated system that embodies
    the principles of least effort and least surprise to a
    substantially greater extent than most comparable languages --
    i.e., you get more bang for your buck, and what you write is more
    likely to give you what you expected to get. Ruby is thus a
    relatively easy to learn, easy to read, and easy to maintain
    language; yet it is very powerful and sophisticated.

    In addition to common OO features, Ruby also has threads,
    singleton methods, mixins, fully integrated closures and
    iterators, plus proper meta-classes. Ruby has a true
    mark-and-sweep garbage collector, which makes code more reliable
    and simplifies writing extensions. In summary, Ruby provides a
    very powerful and very easy to deploy "standing on the shoulders
    of giants" OO scaffolding/framework so that you can more quickly
    and easily build what you want to build, to do what you want to
    do.
    
    You will find many former (and current) Perl, Python, Java, and
    C++ users on comp.lang.ruby that can help you get up to speed in
    Ruby.

    Finally, Ruby is an "open source" development programming
    language.

1.2 Where can I find out more about Ruby?

    If you're into IRC, check out #ruby-lang on FreeNode. There are
    also other channels -- see http://rubygarden.org/ruby?RubyOnIRC.

    There are also many web and print resources listed below:

    Ruby's home web site:
    
        http://www.ruby-lang.org/en/ (Ruby home page)

            Follow the links to documentation, downloads, the Ruby
            Application Archive, the Ruby mail list archives, and
      lots of other interesting information.

    RubyForge (A major repository with hundreds of Ruby projects)

        http://rubyforge.org

    Ruby-Doc.org (A large source of Ruby documentation)
    
    RubyCentral.COM (Ruby's other major on-line docs and links site):
    
        http://www.rubycentral.com/

    RubyCentral.ORG (Home of RubyCentral, Inc.)
    
        http://www.rubycentral.org/

    RubyGarden (An important wiki site, very content-rich)

        http://rubygarden.org/

    Ruby FAQ:
    
        http://www.rubygarden.org/iowa/faqtotum/

    Ruby User's Guide (introductory tutorial):

        http://www.rubyist.net/~slagell/ruby/index.html

    _Why's Poignant Guide to Ruby (A Ruby tutorial on acid, featuring
        cartoon foxes)

        http://poignantguide.net/ruby/

    Note: The list of books below is now frozen. I don't
    want to maintain this forever. We all hope the number
    of Ruby books increases, of course.

    English language Ruby books (recent publication order):

        Programming Ruby: A Pragmatic Programmers Guide
        2nd edition. See below.

        Making Use of Ruby
  by Suresh Mahadevan
  Wiley; ISBN 0-471-21972-X (2002)

        Teach Yourself Ruby in 21 Days
        by Mark Slagell
        Sams; ISBN: 0672322528 (March, 2002)

        Ruby Developer's Guide
        by Michael Neumann, Robert Feldt, Lyle Johnson
        Publishers Group West; ISBN: 1928994644 (February, 2002)

        The Ruby Way
        by Hal Fulton
        Sams; ISBN: 0672320835 (December, 2001)

        Ruby In A Nutshell
        by Yukihiro Matsumoto
        O'Reilly & Associates; ISBN: 0596002149 (November, 2001)

        Programming Ruby: A Pragmatic Programmers Guide
        by Dave Thomas and Andrew Hunt
        Addison Wesley; ISBN: 0201710897 (2000)
        (As of Sept 2004, there is a second edition also. It is
         not open-sourced at this time.)
        Online version: http://www.rubycentral.com/book/
  (Note that this is a *legal* first edition.)
        Download:
    http://www.pragmaticprogrammer.com/downloads/book.html
        Errata:
    http://www.pragmaticprogrammer.com/ruby/errata/errata.html

    German language Ruby books (author alpha order):

        Das Einsteigerseminar Ruby. Der methodische und
        ausführliche Einstieg.
        by Dirk Engel and Klaus Spreckelsen
        ISBN: 3826672429

        Programmieren mit Ruby
        by Armin Roehrl, Stefan Schmiedl, Clemens Wyss, et al.
        dpunkt.de; ISBN 3898641511 (February, 2002)
  Online: http://www.approximity.com/rubybuch2/node1_main.html

        Programmieren mit Ruby. Handbuch für den pragmatischen
        Programmierer.
  Dave Thomas & Andy Hunt
        Addison-Wesley, 2002; ISBN: 382731965X.
        A German translation of the "Pickaxe" (Programming Ruby).

  Pickaxe translation by Juergen Katins:
    http://home.vr-web.de/juergen.katins/ruby/buch/

    Search past postings to comp.lang.ruby or the ruby-lang mail list
    (which have been mirrored to each other since mid-2000):

        http://groups.google.com/groups?q=comp.lang.ruby
        http://blade.nagaokaut.ac.jp/ruby/ruby-talk/index.shtml

    Local Ruby users and groups in your area:

        http://www.pragprog.com/ruby?RubyUserGroups

2 About comp.lang.ruby

2.1 Tell me about comp.lang.ruby

    comp.lang.ruby was officially approved in early May, 2000.
    (Conrad Schneiker, the former maintainer of this FAQ, was
    responsible for the "net paperwork" of creating this group.)
    Here is the official charter:

        CHARTER: comp.lang.ruby

        The comp.lang.ruby newsgroup is devoted to discussions of the
        Ruby programming language and related issues.

        Examples of relevant postings include, but are not limited
        to, the following subjects:

        - Bug reports
        - Announcements of software written with Ruby
        - Examples of Ruby code
        - Suggestions for Ruby developers
        - Requests for help from new Ruby programmers

        The newsgroup is not moderated. Binaries are prohibited
        (except the small PGP type). Advertising is prohibited (except
        for announcements of new Ruby-related products).

        END CHARTER.

2.2 Tell me the posting guidelines for comp.lang.ruby.

    (You should also follow these guidelines for the ruby-list mail
    list, since it is mirrored to comp.lang.ruby.)

    (1) ALWAYS be friendly, considerate, tactful, and tasteful. We
        want to keep this forum hospitable to the growing ranks of
        newbies, very young people, and their teachers, as well as
        cater to fire breathing wizards.

    (2) Keep your content relevant and easy to follow. Try to keep
        your content brief and to the point, but also try to include
        all relevant information.

        (a) The general format guidelines (aka USENET Netiquette) are
            matters of common sense and common courtesy that make life
            easier for 3rd parties to follow along (in real time or
            when perusing archives):

            - PLEASE NOTE! Include quoted text from previous posts
              *BEFORE* your responses. And *selectively* quote as much
              as is relevant.
            - Use *plain* text; don't use HTML, RTF, or Word. Most
              mail or newsreader programs have an option for this; if
              yours doesn't, get a (freeware) program or use a
              web-based service that does.
            - Include examples from files as *in-line* text; don't
              use attachments.

        (b) If reporting a problem, give *all* the relevant
            information the first time; this isn't the psychic friends
            newsgroup. When appropriate, include:

            - The version of Ruby. ("ruby -v")
            - The compiler name and version used to build Ruby.
            - The OS type and level. ("uname -a")
            - The actual error messages.
            - An example (preferably simple) that produces the
              problem.

    (3) Make the subject line maximally informative, so that people
        who should be interested will read your post and so that people
        who wouldn't be interested can easily avoid it.

        *Usefully* describe the contents of your post:

            This is OK:
            
                "How can I do x with y on z?"
                "Problem: did x, expected y, got z."
                "BUG: doing x with module y crashed z."

            This is *NOT* OK:

                "Please help!!!"
                "Newbie question"
                "Need Ruby guru to tell me what's wrong"

      These prefixes have become common for subject lines:

                ANN: (for announcements)
          BUG: (for bug reports)
          OT: (for off-topic, if you must post off-topic)
    
    (4) Finally, be considerate: don't be too lazy. If you are
        seeking information, first make a reasonable effort to look it
        up. As appropriate, check the Ruby home page, check the Ruby
  FAQ and other documentation, use google.com to search past
        comp.lang.ruby postings, and so on.

2.3 Tell me about the prolific Matz poster.

    Matz (aka Yukihiro Matsumoto) is the wizard who created Ruby for
    us, so be nice to him. He is very busy, so be patient when asking
    questions. See the Ruby home page to find out more about him and
    his work. I (Conrad Schneiker) founded comp.lang.ruby at his
    suggestion. Contrary to lots of skepticism, it was approved on
    the first attempt, with 200 yes votes.

2.4 How do the mailing list and newsgroup interrelate?

    The mailing list is older. When the newsgroup was created, they
    diverged. In mid-2001, Dave Thomas created a two-way gateway
    that would "mirror" the newsgroup to the list and vice versa.
    (This was accomplished in 200 lines of Ruby code.) It is not
    perfect; because of variability in the news feed, sometimes
    messages are dropped or duplicated.

    The online archive of the mailing list therefore includes most
    of the traffic on the newsgroup, excluding the posts that were
    made before the creation of the gateway.

    Note: Spam or other inappropriate messages are NOT the
    responsibility of Dave Thomas, who maintains the gateway. He
    does everything in his power to deal with this issue. Do NOT
    report spam to his ISP merely because the messages come from
    his server.

2.5 What are these 6-digit message numbers?

    Historically, every item on the mailing list had a subject
    starting with a string like: [ruby-talk:99999]

    The message numbers were convenient since they were strictly
    serial and formed a good way to refer to a past message. But
    they interfered with threading; Matz removed them after the
    matter was put to a vote in early 2002.

    The news header still refers to this number, should anyone
    wish to retrieve it. On the mailing list this number can
    now be found in the X-Mail-Count: header.

    You can point to a specific message by appending it onto the
    ruby-talk.com URL; i.e. http://ruby-talk.com/12345 will refer
    to message 12345. (NOTE: The above was true, but is not
    currently working.)

2.6 What is "POLS"?

    POLS is an abbreviation for "Principle of Least Surprise" (also
    called the Law of Least Astonishment).

    This term certainly did not originate in the Ruby community, but
    it has been frequently used there -- even overused or abused at
    times. After all, *every* language or software system seeks at
    some level to adhere to this principle. Is any system designed
    to be unintuitive?

    It is inappropriate to invoke POLS as a "magic word" when one's
    individual expectations are not met. Ruby continues to evolve,
    and Matz often makes changes based on people wishes, needs, or
    suggestions. But he cannot be bribed or threatened. Make
    suggestions if you wish, but think twice before mentioning POLS.

3. Anything else?

    If you are new to Ruby (or haven't previously taken the Ruby User
    Survey), please take a moment to anonymously tell us about your
    programming background and about your Ruby-related interests. The
    results will be reported back to the Ruby community from time to
    time. This helps us do a better job of helping each other, and to
    more effectively expand the Ruby community for our mutual benefit.
    The survey is at:

        http://dev.rubycentral.com/survey.html

    This FAQ was originally produced by Conrad Schneiker.
    It is now maintained by Hal Fulton (hal9000@hypermetrics.com).
    I'm interested in corrections and suggestions, but remember that
    the purpose of this FAQ is to be a brief and simple introduction
    for new comp.lang.ruby readers.
    
    In closing, one of the reasons that Ruby was designed to be
    relatively simple, uniform, yet very powerful was to make serious
    programming (among other kinds) fun. We hope you will help us
    keep comp.lang.ruby fun as well. Enjoy.

(Ben Giddings) #2

Hey Hal (and everybody else),

It seems to me the FAQ is in need of a bit of an update. For one thing,
Matz isn't really all that a prolific poster (and hasn't been for a couple
of years). In fact, according to recent stats he doesn't even make the
top 10 posters.

Maybe the question should just be reworded as "Who is this 'Matz' guy that
people keep mentioning?"

Also, maybe we could reduce the number of duplicate threads on Ruby vs.
[Foo] and benchmarking Ruby if we addressed them in the FAQ. Something
like:

3. Comparing Ruby and other languages
  3.1 How does Ruby compare to Python?
  3.2 How do I make Java-like "Interfaces" in Ruby?
  3.3 How does Ruby's Object Orientedness compare to Java?
  3.4 How fast is Ruby? (and other benchmarking issues)

3.1
Ruby and Python are very similar, so they are often compared. In summary,
they are similar languages with slightly different approaches. Python
emphasizes uniformity of code over options (there should be one -- and
preferably only one -- obvious way to do it). Ruby, on the other hand,
emphasizes practicality over uniformity, and has multiple ways of doing
the same thing. In the end, it's a matter of personal preference. Read
more about this ongoing discussion here:

http://blade.nagaokaut.ac.jp/cgi-bin/vframe.rb/ruby/ruby-talk/125682?125671-126412

(maybe a few more links to classic discussions)

3.2
As a statically typed language, Java requires interfaces to enforce
type-checking rules, and because of that, has Interfaces. Ruby uses
dynamic typing, and so interfaces are less useful. Instead, Ruby most
often uses so-called "duck typing". If it walks like a duck, and quacks
like a duck, it's a duck.

What that means is that Instead of checking to see if an object you are
passed is of the type you expect, the duck-typing way is to try to treat
it as if it's the right type, and then recover gracefully from any errors
that may result. This makes your code much more flexible.

See more on Duck Typing at:

http://blade.nagaokaut.ac.jp/cgi-bin/vframe.rb/ruby/ruby-talk/100511?100299-101528

3.3

After a certain point, trying to decide whether language A or language B is
more "Object Oriented" is an exercise in futility. Having said that,
there are significant differences in the Ruby approach to Object Oriented
programming, as compared to most other languages.

For example, in Java there are two things used to represent integers. One
is the primitive type "int", the other is the class "Integer". While Java
1.5 introduced autoboxing (automatically converting between the two) the
distinction is still there, and can lead to some confusion. In Ruby,
every object is a descendent of the "Object" type. This means that not
only are variables containing integers objects, but bare numbers are
objects as well, allowing you to do things like:

3.times { puts "Hello!" }

3.4

As the saying goes, "There are Lies, Damn Lies, and Benchmarks".

To be perfectly honest, Ruby scores fairly low on most benchmarks. Despite
that, the number of people using Ruby keeps growing. Why? Because, for
the most part, benchmarks don't really reflect real-world use. Aside from
that, benchmarks also don't include development time, debugging time, or
any other factor that is a real cost of development.

Ruby is an interpreted language, and has about the speed you would expect
from that sort of language. In particular, it is significantly slower
than programs compiled to native machine code (C, C++), slightly slower
than byte-code compiled programs (.NET, Python, Lisp), and slightly faster
than most interpreted languages (PHP, Javascript, interpreted Lisp).

If speed is truly a major concern, Ruby has a very clean C interface,
allowing speed-critical code to be compiled and run in machine language.

···

On Monday 15 August 2005 13:45, hal9000@hypermetrics.com wrote:

RUBY NEWSGROUP FAQ -- Welcome to comp.lang.ruby! (Revised 2005-4-14)

*****

Also, should probably have a Rails question/answer in there, so that people
know about the Rails lists.

Feel free to correct/enhance/update/change, etc. I just think it would
help to have some kind of FAQ entry on these things to reduce some of the
more frequent threads.

Ben

(James Britt) #3

Ben Giddings wrote:

RUBY NEWSGROUP FAQ -- Welcome to comp.lang.ruby! (Revised 2005-4-14)

Hey Hal (and everybody else),

It seems to me the FAQ is in need of a bit of an update. For one thing, Matz isn't really all that a prolific poster (and hasn't been for a couple of years). In fact, according to recent stats he doesn't even make the top 10 posters.

Quantity, quality, etc.

Maybe the question should just be reworded as "Who is this 'Matz' guy that people keep mentioning?"

Also, maybe we could reduce the number of duplicate threads on Ruby vs. [Foo] and benchmarking Ruby if we addressed them in the FAQ. Something like:

3. Comparing Ruby and other languages
  3.1 How does Ruby compare to Python?
  3.2 How do I make Java-like "Interfaces" in Ruby?
  3.3 How does Ruby's Object Orientedness compare to Java?
  3.4 How fast is Ruby? (and other benchmarking issues)

3.1

<snip/>

I'm leery of the FAQ having what may be construed as an "official" position on, or synopsis of, other languages. Links to assorted resources, including language home pages, works better for me.

http://blade.nagaokaut.ac.jp/cgi-bin/vframe.rb/ruby/ruby-talk/125682?125671-126412

(maybe a few more links to classic discussions)

Perhaps

   http://www.ruby-doc.org/RubyEyeForThePythonGuy.html

though I have not updated it in a while.

*****

Also, should probably have a Rails question/answer in there, so that people know about the Rails lists.

And Nitro, and Wee, and many, many other good Ruby applications.

Or maybe just a general explanation of where to look for Ruby code (RAA, RubyForge, CodeZoo, ... )

James

···

On Monday 15 August 2005 13:45, hal9000@hypermetrics.com wrote:

--

http://www.ruby-doc.org - The Ruby Documentation Site
http://www.rubyxml.com - News, Articles, and Listings for Ruby & XML
http://www.rubystuff.com - The Ruby Store for Ruby Stuff
http://www.jamesbritt.com - Playing with Better Toys

(Jeff Wood) #4

A lot has changed in Python in the last two releases ( 2.3 & 2.4 ) ...
It's definately time for an update... They copied a lot of our
features :wink:

j.

···

On 8/15/05, James Britt <james_b@neurogami.com> wrote:

Ben Giddings wrote:
> On Monday 15 August 2005 13:45, hal9000@hypermetrics.com wrote:
>
>>RUBY NEWSGROUP FAQ -- Welcome to comp.lang.ruby! (Revised 2005-4-14)
>
>
> Hey Hal (and everybody else),
>
> It seems to me the FAQ is in need of a bit of an update. For one thing,
> Matz isn't really all that a prolific poster (and hasn't been for a couple
> of years). In fact, according to recent stats he doesn't even make the
> top 10 posters.

Quantity, quality, etc.

>
> Maybe the question should just be reworded as "Who is this 'Matz' guy that
> people keep mentioning?"
>
> Also, maybe we could reduce the number of duplicate threads on Ruby vs.
> [Foo] and benchmarking Ruby if we addressed them in the FAQ. Something
> like:
>
> 3. Comparing Ruby and other languages
> 3.1 How does Ruby compare to Python?
> 3.2 How do I make Java-like "Interfaces" in Ruby?
> 3.3 How does Ruby's Object Orientedness compare to Java?
> 3.4 How fast is Ruby? (and other benchmarking issues)
>
> 3.1

<snip/>

I'm leery of the FAQ having what may be construed as an "official"
position on, or synopsis of, other languages. Links to assorted
resources, including language home pages, works better for me.

>
> http://blade.nagaokaut.ac.jp/cgi-bin/vframe.rb/ruby/ruby-talk/125682?125671-126412
>
> (maybe a few more links to classic discussions)
>

Perhaps

   http://www.ruby-doc.org/RubyEyeForThePythonGuy.html

though I have not updated it in a while.

> *****
>
> Also, should probably have a Rails question/answer in there, so that people
> know about the Rails lists.

And Nitro, and Wee, and many, many other good Ruby applications.

Or maybe just a general explanation of where to look for Ruby code (RAA,
RubyForge, CodeZoo, ... )

James

--

http://www.ruby-doc.org - The Ruby Documentation Site
http://www.rubyxml.com - News, Articles, and Listings for Ruby & XML
http://www.rubystuff.com - The Ruby Store for Ruby Stuff
http://www.jamesbritt.com - Playing with Better Toys

--
"So long, and thanks for all the fish"

Jeff Wood

(Ben Giddings) #5

> It seems to me the FAQ is in need of a bit of an update. For one

thing,

> Matz isn't really all that a prolific poster (and hasn't been for a

couple

> of years). In fact, according to recent stats he doesn't even make the
> top 10 posters.

Quantity, quality, etc.

Right, but prolific: "producing a great number or amount of something".

> Also, should probably have a Rails question/answer in there, so that

people

> know about the Rails lists.

And Nitro, and Wee, and many, many other good Ruby applications.

No, just Rails. It's supposed to be a FAQ, and we frequently get questions
about Rails (a few threads each week), but very infrequently about Nitro
or Wee.

Ben

···

On Monday 15 August 2005 17:10, James Britt wrote:

(Austin Ziegler) #6

I disagree. Rails may be the first FAQ, but there is the occasional
question about "other frameworks." The comp.lang.ruby FAQ shouldn't
become Yet Another Advertisement for Rails.

-austin

···

On 8/15/05, Ben Giddings <bg-rubytalk@infofiend.com> wrote:

> And Nitro, and Wee, and many, many other good Ruby applications.
No, just Rails. It's supposed to be a FAQ, and we frequently get questions
about Rails (a few threads each week), but very infrequently about Nitro
or Wee.

--
Austin Ziegler * halostatue@gmail.com
               * Alternate: austin@halostatue.ca

(Ben Giddings) #7

It's not meant to be an ad though, it's supposed to answer frequently asked
questions. We get frequent questions about Rails (a few every week) but
almost none about other frameworks. I have no objection at all to
mentioning other frameworks, even in the Rails answer, but let's keep the
purpose of the document in mind. A FAQ exists so that the same questions
aren't asked over and over, and the questions being asked are almost all
about Rails, not about Nitro, Wee, Hobix, Typo, or any other web-related
app.

So, what about this for FAQs and answers?

4. Web applications in Ruby
4.1 How can I get help with my Rails questions?
4.2 Are there other web applications in Ruby?

The answer to 4.1 can point them to the Rails mailing lists, docs sites,
the rails book, etc.

The answer to 4.2 can summarize all the other web apps.

Sure, this gives Rails more prominence than the other frameworks, but this
just reflects reality, and the reality is that there are far more Rails
questions than there are Nitro questions.

Sound fair?

Ben

···

On Monday 15 August 2005 17:40, Austin Ziegler wrote:

I disagree. Rails may be the first FAQ, but there is the occasional
question about "other frameworks." The comp.lang.ruby FAQ shouldn't
become Yet Another Advertisement for Rails.

(Mark Volkmann) #8

This seems fair to me.

···

On 8/15/05, Ben Giddings <bg-rubytalk@infofiend.com> wrote:

On Monday 15 August 2005 17:40, Austin Ziegler wrote:
> I disagree. Rails may be the first FAQ, but there is the occasional
> question about "other frameworks." The comp.lang.ruby FAQ shouldn't
> become Yet Another Advertisement for Rails.

It's not meant to be an ad though, it's supposed to answer frequently asked
questions. We get frequent questions about Rails (a few every week) but
almost none about other frameworks. I have no objection at all to
mentioning other frameworks, even in the Rails answer, but let's keep the
purpose of the document in mind. A FAQ exists so that the same questions
aren't asked over and over, and the questions being asked are almost all
about Rails, not about Nitro, Wee, Hobix, Typo, or any other web-related
app.

So, what about this for FAQs and answers?

4. Web applications in Ruby
4.1 How can I get help with my Rails questions?
4.2 Are there other web applications in Ruby?

The answer to 4.1 can point them to the Rails mailing lists, docs sites,
the rails book, etc.

The answer to 4.2 can summarize all the other web apps.

Sure, this gives Rails more prominence than the other frameworks, but this
just reflects reality, and the reality is that there are far more Rails
questions than there are Nitro questions.

Sound fair?

--
R. Mark Volkmann
Partner, Object Computing, Inc.